58 global $wgTranslateSandboxLimit;
65 MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_PRIMARY )
67 $user = RequestContext::getMain()->getUser();
68 $translations = $store->getTranslations( $user );
72 foreach ( $translations as $translation ) {
73 $title = $translation->getTitle();
75 $index = $title->getNamespace() .
':' . $handle->getKey();
80 $all = Services::getInstance()->getMessageIndex()->getKeys();
86 $max = count( $all ) - 1;
89 for ( $i = count( $list ); $i < 100; $i++ ) {
90 $list[$all[rand( $min, $max )]] =
'';
98 $messagesToProvide = $wgTranslateSandboxLimit * 2;
100 foreach ( $list as $index => &$translation ) {
101 [ $ns, $page ] = explode(
':', $index, 2 );
102 $title = Title::makeTitle( (
int)$ns,
"$page/{$this->language}" );
105 if ( MessageGroups::isTranslatableMessage( $handle, $this->language ) ) {
108 if ( $translation ===
null ) {
110 unset( $list[$index] );
111 wfWarn(
"No message definition for $index while preparing the sandbox" );
118 unset( $list[$index] );
125 if ( $count === $messagesToProvide ) {
131 $list = array_slice( $list, 0, $messagesToProvide );
146 $groupId = Services::getInstance()->getMessageIndex()->getPrimaryGroupId( $handle );
147 if ( $groupId ===
null ) {
150 $group = MessageGroups::getGroup( $groupId );
153 $source = $group->getMessage( $key, $group->getSourceLanguage() );
154 if ( $source !==
null ) {
159 $keys = $group->getKeys();
162 foreach ( $keys as $realkey ) {
163 if ( $key === strtolower( $realkey ) ) {
169 return $group->getMessage( $key, $group->getSourceLanguage() );