Index: trunk/extensions/JS2Support/mwEmbed/mwEmbed.i18n.php |
— | — | @@ -0,0 +1,272 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Localization file for mwEmbed.js |
| 5 | + */ |
| 6 | +$messages['en'] = array( |
| 7 | + 'mwe-loading_txt' => 'Loading ...', |
| 8 | + 'mwe-size-gigabytes' => '$1 GB', |
| 9 | + 'mwe-size-megabytes' => '$1 MB', |
| 10 | + 'mwe-size-kilobytes' => '$1 K', |
| 11 | + 'mwe-size-bytes' => '$1 B', |
| 12 | + 'mwe-error_load_lib' => 'Error: JavaScript $1 was not retrievable or does not define $2', |
| 13 | + 'mwe-apiproxy-setup' => 'Setting up API proxy', |
| 14 | + 'mwe-load-drag-item' => 'Loading dragged item', |
| 15 | + 'mwe-ok' => 'OK', |
| 16 | + 'mwe-cancel' => 'Cancel', |
| 17 | + 'mwe-enable-gadget' => 'Enable multimedia beta ( mwEmbed ) for all pages', |
| 18 | + 'mwe-enable-gadget-done' => 'multimedia beta gadget has been enabled', |
| 19 | + 'mwe-must-login-gadget' => 'To enable gadget you must <a target="_new" href="$1">login</a>', |
| 20 | + 'mwe-test-plural' => 'I ran {{PLURAL:$1|$1 test|$1 tests}}', |
| 21 | +); |
| 22 | +$messages['af'] = array( |
| 23 | + 'mwe-loading_txt' => 'laai ...', |
| 24 | + 'mwe-error_load_lib' => 'Fout: JavaScript $1 kon nie gevind word of definieer nie $2 nie', |
| 25 | + 'mwe-ok' => 'OK', |
| 26 | + 'mwe-cancel' => 'Kanselleer', |
| 27 | +); |
| 28 | +$messages['ar'] = array( |
| 29 | + 'mwe-loading_txt' => 'يحمل...', |
| 30 | + 'mwe-cancel' => 'ألغِ', |
| 31 | +); |
| 32 | +$messages['be-tarask'] = array( |
| 33 | + 'mwe-loading_txt' => 'загрузка …', |
| 34 | + 'mwe-error_load_lib' => 'Памылка: JavaScript $1 не даступны альбо не вызначае $2', |
| 35 | + 'mwe-apiproxy-setup' => 'Устаноўка API-проксі', |
| 36 | + 'mwe-load-drag-item' => 'Загрузка перанесенага элемэнту', |
| 37 | + 'mwe-ok' => 'Добра', |
| 38 | + 'mwe-cancel' => 'Адмяніць', |
| 39 | +); |
| 40 | +$messages['br'] = array( |
| 41 | + 'mwe-loading_txt' => 'o kargañ...', |
| 42 | + 'mwe-ok' => 'Mat eo', |
| 43 | + 'mwe-cancel' => 'Nullañ', |
| 44 | +); |
| 45 | +$messages['bs'] = array( |
| 46 | + 'mwe-loading_txt' => 'učitavam ...', |
| 47 | + 'mwe-apiproxy-setup' => 'Postavljanje API proksija', |
| 48 | + 'mwe-ok' => 'U redu', |
| 49 | + 'mwe-cancel' => 'Odustani', |
| 50 | +); |
| 51 | +$messages['cs'] = array( |
| 52 | + 'mwe-loading_txt' => 'Načítá se …', |
| 53 | + 'mwe-cancel' => 'Storno', |
| 54 | +); |
| 55 | +$messages['cy'] = array( |
| 56 | + 'mwe-loading_txt' => 'wrthi\'n llwytho ...', |
| 57 | +); |
| 58 | +$messages['de'] = array( |
| 59 | + 'mwe-loading_txt' => 'lade …', |
| 60 | + 'mwe-error_load_lib' => 'Fehler: JavaScript $1 war nicht abrufbar oder lässt $2 nicht zu', |
| 61 | + 'mwe-apiproxy-setup' => 'API-Proxy-Konfiguration', |
| 62 | + 'mwe-ok' => 'OK', |
| 63 | + 'mwe-cancel' => 'Abbrechen', |
| 64 | +); |
| 65 | +$messages['diq'] = array( |
| 66 | + 'mwe-loading_txt' => 'bar beno...', |
| 67 | + 'mwe-error_load_lib' => 'xeta: $1 JavaScript re nêresiyeno ya zi pê $2yi şınasnaye niyo.', |
| 68 | + 'mwe-apiproxy-setup' => 'proxyê APIyi eyar beno', |
| 69 | + 'mwe-load-drag-item' => 'unsur bar beno', |
| 70 | + 'mwe-ok' => 'temam', |
| 71 | + 'mwe-cancel' => 'iptal', |
| 72 | +); |
| 73 | +$messages['dsb'] = array( |
| 74 | + 'mwe-loading_txt' => 'zacytujo se ...', |
| 75 | + 'mwe-error_load_lib' => 'Zmólka: JavaScript $1 njejo wótwołujobny był abo njedefiněrujo $2', |
| 76 | + 'mwe-apiproxy-setup' => 'Proksy API zarědowaś', |
| 77 | + 'mwe-load-drag-item' => 'Wlecony zapisk se zacytujo', |
| 78 | + 'mwe-ok' => 'W pórědku', |
| 79 | + 'mwe-cancel' => 'Pśetergnuś', |
| 80 | +); |
| 81 | +$messages['el'] = array( |
| 82 | + 'mwe-loading_txt' => 'φόρτωση ...', |
| 83 | +); |
| 84 | +$messages['eo'] = array( |
| 85 | + 'mwe-loading_txt' => 'ŝarĝante ...', |
| 86 | + 'mwe-cancel' => 'Nuligi', |
| 87 | +); |
| 88 | +$messages['es'] = array( |
| 89 | + 'mwe-loading_txt' => 'cargando ...', |
| 90 | + 'mwe-load-drag-item' => 'Cargando el objeto arrastrado', |
| 91 | + 'mwe-ok' => 'OK', |
| 92 | + 'mwe-cancel' => 'Cancelar', |
| 93 | +); |
| 94 | +$messages['eu'] = array( |
| 95 | + 'mwe-loading_txt' => 'Kargatzen ...', |
| 96 | + 'mwe-ok' => 'Ados', |
| 97 | + 'mwe-cancel' => 'Ezeztatu', |
| 98 | +); |
| 99 | +$messages['fi'] = array( |
| 100 | + 'mwe-cancel' => 'Peruuta', |
| 101 | +); |
| 102 | +$messages['fr'] = array( |
| 103 | + 'mwe-loading_txt' => 'chargement ...', |
| 104 | + 'mwe-error_load_lib' => 'Erreur : JavaScript $1 n\'a pas pu être trouvé ou ne définit pas $2', |
| 105 | + 'mwe-apiproxy-setup' => 'Configuration du proxy API', |
| 106 | + 'mwe-load-drag-item' => 'Chargement de l’élément dépose', |
| 107 | + 'mwe-ok' => 'OK', |
| 108 | + 'mwe-cancel' => 'Annuler', |
| 109 | +); |
| 110 | +$messages['gl'] = array( |
| 111 | + 'mwe-loading_txt' => 'cargando...', |
| 112 | + 'mwe-error_load_lib' => 'Erro: o JavaScript $1 non se puido atopar ou non definía $2', |
| 113 | + 'mwe-apiproxy-setup' => 'Configurando o proxy API', |
| 114 | + 'mwe-load-drag-item' => 'Cargando o elemento arrastrado', |
| 115 | + 'mwe-ok' => 'De acordo', |
| 116 | + 'mwe-cancel' => 'Cancelar', |
| 117 | +); |
| 118 | +$messages['gsw'] = array( |
| 119 | + 'mwe-loading_txt' => 'Am Lade ...', |
| 120 | + 'mwe-error_load_lib' => 'Fähler: s JavaScript $1 het nit chenne glade wäre oder s losst $2 nit zue', |
| 121 | + 'mwe-apiproxy-setup' => 'API-Proxy-Konfiguration', |
| 122 | + 'mwe-load-drag-item' => 'Am Lade vu mitgschleipfte Poschte', |
| 123 | + 'mwe-ok' => 'OK', |
| 124 | + 'mwe-cancel' => 'Abbräche', |
| 125 | +); |
| 126 | +$messages['he'] = array( |
| 127 | + 'mwe-loading_txt' => 'בטעינה ...', |
| 128 | + 'mwe-error_load_lib' => 'שגיאה: לא ניתן היה לטעון את ספריית ה־JavaScript בשם $1 או שהיא אינה מגדירה את $2', |
| 129 | +); |
| 130 | +$messages['hsb'] = array( |
| 131 | + 'mwe-loading_txt' => 'začituje so ...', |
| 132 | + 'mwe-size-gigabytes' => '$1 GB', |
| 133 | + 'mwe-size-megabytes' => '$1 MB', |
| 134 | + 'mwe-size-kilobytes' => '$1 KB', |
| 135 | + 'mwe-size-bytes' => '$1 B', |
| 136 | + 'mwe-error_load_lib' => 'Zmylk: JavaScript $1 njeda so wotwołać abo njedefinuje $2', |
| 137 | + 'mwe-apiproxy-setup' => 'Proksy API zarjadować', |
| 138 | + 'mwe-load-drag-item' => 'Wlečeny zapisk so začituje', |
| 139 | + 'mwe-ok' => 'W porjadku', |
| 140 | + 'mwe-cancel' => 'Přetorhnyć', |
| 141 | +); |
| 142 | +$messages['hu'] = array( |
| 143 | + 'mwe-loading_txt' => 'betöltés…', |
| 144 | + 'mwe-error_load_lib' => 'Hiba: a(z) $1 JavaScript-fájl nem elérhető, vagy nem definiálja a(z) $2 osztályt.', |
| 145 | + 'mwe-apiproxy-setup' => 'API proxy beállítása', |
| 146 | + 'mwe-load-drag-item' => 'Vonszolt elem betöltése', |
| 147 | + 'mwe-ok' => 'OK', |
| 148 | + 'mwe-cancel' => 'Mégse', |
| 149 | +); |
| 150 | +$messages['ia'] = array( |
| 151 | + 'mwe-loading_txt' => 'cargamento ...', |
| 152 | + 'mwe-error_load_lib' => 'Error: JavaScript $1 non esseva recuperabile o non defini $2', |
| 153 | + 'mwe-apiproxy-setup' => 'Configuration del proxy pro le API', |
| 154 | + 'mwe-load-drag-item' => 'Cargamento del file trahite', |
| 155 | + 'mwe-ok' => 'OK', |
| 156 | + 'mwe-cancel' => 'Cancella', |
| 157 | +); |
| 158 | +$messages['id'] = array( |
| 159 | + 'mwe-loading_txt' => 'memuat...', |
| 160 | + 'mwe-error_load_lib' => 'Kesalahan: JavaScript $1 tidak dapat diambil atau tidak mendefinisikan $2', |
| 161 | + 'mwe-apiproxy-setup' => 'Menyiapkan proksi API', |
| 162 | + 'mwe-load-drag-item' => 'Memuat butir terseret', |
| 163 | + 'mwe-ok' => 'Oke', |
| 164 | + 'mwe-cancel' => 'Batalkan', |
| 165 | +); |
| 166 | +$messages['it'] = array( |
| 167 | + 'mwe-cancel' => 'Annulla', |
| 168 | +); |
| 169 | +$messages['ja'] = array( |
| 170 | + 'mwe-loading_txt' => '読み込み中 …', |
| 171 | + 'mwe-error_load_lib' => 'エラー:JavaScript $1 は参照不能か、$2 を定義していません。', |
| 172 | + 'mwe-apiproxy-setup' => 'API プロキシーをセットアップ中', |
| 173 | + 'mwe-load-drag-item' => 'ドラッグされた項目を読み込み中', |
| 174 | + 'mwe-ok' => 'OK', |
| 175 | + 'mwe-cancel' => '中止', |
| 176 | +); |
| 177 | +$messages['ko'] = array( |
| 178 | + 'mwe-loading_txt' => '불러오는 중...', |
| 179 | + 'mwe-cancel' => '취소', |
| 180 | +); |
| 181 | +$messages['ksh'] = array( |
| 182 | + 'mwe-loading_txt' => 'aam Laade …', |
| 183 | + 'mwe-size-gigabytes' => '$1 GB', |
| 184 | + 'mwe-size-megabytes' => '$1 MB', |
| 185 | + 'mwe-size-kilobytes' => '$1 KB', |
| 186 | + 'mwe-size-bytes' => '$1 Bytes', |
| 187 | + 'mwe-error_load_lib' => 'Fähler: Dat JavaSkrep „<code lang="en">$1</code>“ wohr nit ze laade udder et leiht „<code lang="en">$2</code>“ nit faß.', |
| 188 | + 'mwe-cancel' => 'Affbräsche', |
| 189 | +); |
| 190 | +$messages['lb'] = array( |
| 191 | + 'mwe-loading_txt' => 'lueden ...', |
| 192 | + 'mwe-apiproxy-setup' => 'API-Proxy astellen', |
| 193 | + 'mwe-ok' => 'OK', |
| 194 | + 'mwe-cancel' => 'Ofbriechen', |
| 195 | +); |
| 196 | +$messages['ml'] = array( |
| 197 | + 'mwe-loading_txt' => 'ശേഖരിക്കുന്നു ...', |
| 198 | + 'mwe-error_load_lib' => 'പിശക്: ജാവാസ്ക്രിപ്റ്റ് $1 ശേഖരിക്കാൻ കഴിഞ്ഞില്ല അല്ലെങ്കിൽ $2 നിർവ്വചിച്ചിട്ടില്ല', |
| 199 | + 'mwe-apiproxy-setup' => 'എ.പി.ഐ. പ്രോക്സി സജ്ജീകരിക്കുക', |
| 200 | + 'mwe-load-drag-item' => 'വലിച്ചിട്ടത് ശേഖരിക്കുന്നു', |
| 201 | + 'mwe-ok' => 'ശരി', |
| 202 | + 'mwe-cancel' => 'റദ്ദാക്കുക', |
| 203 | +); |
| 204 | +$messages['nl'] = array( |
| 205 | + 'mwe-loading_txt' => 'bezig met laden ...', |
| 206 | + 'mwe-error_load_lib' => 'Fout: JavaScript $1 kon niet opgehaald worden of definieert $2 niet', |
| 207 | + 'mwe-apiproxy-setup' => 'Bezig met het opzetten van een API-proxy', |
| 208 | + 'mwe-load-drag-item' => 'Bezig met het laden van het gesleepte bestand', |
| 209 | + 'mwe-ok' => 'OK', |
| 210 | + 'mwe-cancel' => 'Annuleren', |
| 211 | +); |
| 212 | +$messages['oc'] = array( |
| 213 | + 'mwe-loading_txt' => 'cargament ...', |
| 214 | + 'mwe-error_load_lib' => 'Error : JavaScript $1 a pas pogut èsser trobat o definís pas $2', |
| 215 | + 'mwe-apiproxy-setup' => 'Configuracion del proxy API', |
| 216 | + 'mwe-load-drag-item' => 'Cargament de l’element depausat', |
| 217 | + 'mwe-ok' => 'OK', |
| 218 | + 'mwe-cancel' => 'Anullar', |
| 219 | +); |
| 220 | +$messages['pdc'] = array( |
| 221 | + 'mwe-ok' => 'OK', |
| 222 | +); |
| 223 | +$messages['pl'] = array( |
| 224 | + 'mwe-loading_txt' => 'ładowanie ...', |
| 225 | + 'mwe-error_load_lib' => 'Błąd – W plik JavaScript $1 brak jest możliwości pobrania oraz definicji $2', |
| 226 | +); |
| 227 | +$messages['pt'] = array( |
| 228 | + 'mwe-loading_txt' => 'A carregar ...', |
| 229 | + 'mwe-error_load_lib' => 'Erro: O JavaScript $1 não pode ser importado ou não define $2', |
| 230 | + 'mwe-apiproxy-setup' => 'A preparar o \'\'proxy\'\' da API', |
| 231 | + 'mwe-load-drag-item' => 'Carregando o objecto arrastado', |
| 232 | + 'mwe-ok' => 'OK', |
| 233 | + 'mwe-cancel' => 'Cancelar', |
| 234 | +); |
| 235 | +$messages['ru'] = array( |
| 236 | + 'mwe-loading_txt' => 'загрузка …', |
| 237 | + 'mwe-error_load_lib' => 'Ошибка. JavaScript $1 не доступен или не определяет $2', |
| 238 | + 'mwe-apiproxy-setup' => 'Настройка API-прокси', |
| 239 | + 'mwe-load-drag-item' => 'Загрузка перетащенного элемента', |
| 240 | + 'mwe-ok' => 'OK', |
| 241 | + 'mwe-cancel' => 'Отмена', |
| 242 | +); |
| 243 | +$messages['sk'] = array( |
| 244 | + 'mwe-loading_txt' => 'načítava sa ...', |
| 245 | + 'mwe-error_load_lib' => 'Error: JavaScript $1 nebolo možné získať alebo neobsahuje definíciu $2', |
| 246 | +); |
| 247 | +$messages['sv'] = array( |
| 248 | + 'mwe-ok' => 'OK', |
| 249 | + 'mwe-cancel' => 'Avbryt', |
| 250 | +); |
| 251 | +$messages['te'] = array( |
| 252 | + 'mwe-ok' => 'సరే', |
| 253 | + 'mwe-cancel' => 'రద్దుచేయి', |
| 254 | +); |
| 255 | +$messages['tr'] = array( |
| 256 | + 'mwe-loading_txt' => 'yükleniyor ...', |
| 257 | + 'mwe-error_load_lib' => 'Hata: $1 JavaScripti erişilebilir değil ya da $2 tanımlı değil', |
| 258 | + 'mwe-apiproxy-setup' => 'API vekili ayarlanıyor', |
| 259 | + 'mwe-load-drag-item' => 'Sürüklenen öğe yükleniyor', |
| 260 | + 'mwe-ok' => 'Tamam', |
| 261 | + 'mwe-cancel' => 'İptal', |
| 262 | +); |
| 263 | +$messages['vec'] = array( |
| 264 | + 'mwe-loading_txt' => 'so\' drio cargar ...', |
| 265 | + 'mwe-ok' => 'Va ben', |
| 266 | + 'mwe-cancel' => 'Anula', |
| 267 | +); |
| 268 | +$messages['vi'] = array( |
| 269 | + 'mwe-loading_txt' => 'đang tải …', |
| 270 | + 'mwe-size-kilobytes' => '$1 kB', |
| 271 | + 'mwe-ok' => 'OK', |
| 272 | + 'mwe-cancel' => 'Hủy bỏ', |
| 273 | +); |
Property changes on: trunk/extensions/JS2Support/mwEmbed/mwEmbed.i18n.php |
___________________________________________________________________ |
Name: svn:mergeinfo |
1 | 274 | + |
Index: trunk/extensions/JS2Support/mwEmbed/includes/jsClassLoader.php |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | self::$classesLoaded = true; |
| 41 | + |
41 | 42 | // Start the profiler if running |
42 | 43 | $fname = 'jsClassLoader::loadClassPaths'; |
43 | 44 | wfProfileIn( $fname ); |
— | — | @@ -44,7 +45,7 @@ |
45 | 46 | |
46 | 47 | $mwEmbedAbsolutePath = ( $wgMwEmbedDirectory == '' ) ? $IP : $IP .'/' .$wgMwEmbedDirectory; |
47 | 48 | // Add the mwEmbed localizations |
48 | | - $wgExtensionMessagesFiles[ 'mwEmbed' ] = $mwEmbedAbsolutePath . '/languages/mwEmbed.i18n.php'; |
| 49 | + $wgExtensionMessagesFiles[ 'mwEmbed' ] = $mwEmbedAbsolutePath . '/mwEmbed.i18n.php'; |
49 | 50 | |
50 | 51 | |
51 | 52 | // Load javascript classes from mwEmbed.js |
— | — | @@ -75,6 +76,13 @@ |
76 | 77 | $fileContent |
77 | 78 | ); |
78 | 79 | |
| 80 | + // Change to the root mediawiki directory ( loader.js paths are relative to root mediawiki directory ) |
| 81 | + // ( helpful for when running maintenance scripts ) |
| 82 | + if( defined( 'DO_MAINTENANCE' ) ) { |
| 83 | + $initialPath = getcwd(); |
| 84 | + chdir( $IP ); |
| 85 | + } |
| 86 | + |
79 | 87 | // Get all the classes from the enabled mwEmbed modules folder |
80 | 88 | foreach( self::$moduleList as $na => $moduleName){ |
81 | 89 | $relativeSlash = ( $wgMwEmbedDirectory == '' )? '' : '/'; |
— | — | @@ -88,6 +96,10 @@ |
89 | 97 | self::proccessModulePath( $modulePath ); |
90 | 98 | } |
91 | 99 | |
| 100 | + if( defined( 'DO_MAINTENANCE' ) ) { |
| 101 | + chdir( $initialPath ); |
| 102 | + } |
| 103 | + |
92 | 104 | wfProfileOut( $fname ); |
93 | 105 | } |
94 | 106 | /** |
Index: trunk/extensions/JS2Support/mwEmbed/languages/mwEmbed.i18n.php |
— | — | @@ -1,272 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Localization file for mwEmbed.js |
5 | | - */ |
6 | | -$messages['en'] = array( |
7 | | - 'mwe-loading_txt' => 'Loading ...', |
8 | | - 'mwe-size-gigabytes' => '$1 GB', |
9 | | - 'mwe-size-megabytes' => '$1 MB', |
10 | | - 'mwe-size-kilobytes' => '$1 K', |
11 | | - 'mwe-size-bytes' => '$1 B', |
12 | | - 'mwe-error_load_lib' => 'Error: JavaScript $1 was not retrievable or does not define $2', |
13 | | - 'mwe-apiproxy-setup' => 'Setting up API proxy', |
14 | | - 'mwe-load-drag-item' => 'Loading dragged item', |
15 | | - 'mwe-ok' => 'OK', |
16 | | - 'mwe-cancel' => 'Cancel', |
17 | | - 'mwe-enable-gadget' => 'Enable multimedia beta ( mwEmbed ) for all pages', |
18 | | - 'mwe-enable-gadget-done' => 'multimedia beta gadget has been enabled', |
19 | | - 'mwe-must-login-gadget' => 'To enable gadget you must <a target="_new" href="$1">login</a>', |
20 | | - 'mwe-test-plural' => 'I ran {{PLURAL:$1|$1 test|$1 tests}}', |
21 | | -); |
22 | | -$messages['af'] = array( |
23 | | - 'mwe-loading_txt' => 'laai ...', |
24 | | - 'mwe-error_load_lib' => 'Fout: JavaScript $1 kon nie gevind word of definieer nie $2 nie', |
25 | | - 'mwe-ok' => 'OK', |
26 | | - 'mwe-cancel' => 'Kanselleer', |
27 | | -); |
28 | | -$messages['ar'] = array( |
29 | | - 'mwe-loading_txt' => 'يحمل...', |
30 | | - 'mwe-cancel' => 'ألغِ', |
31 | | -); |
32 | | -$messages['be-tarask'] = array( |
33 | | - 'mwe-loading_txt' => 'загрузка …', |
34 | | - 'mwe-error_load_lib' => 'Памылка: JavaScript $1 не даступны альбо не вызначае $2', |
35 | | - 'mwe-apiproxy-setup' => 'Устаноўка API-проксі', |
36 | | - 'mwe-load-drag-item' => 'Загрузка перанесенага элемэнту', |
37 | | - 'mwe-ok' => 'Добра', |
38 | | - 'mwe-cancel' => 'Адмяніць', |
39 | | -); |
40 | | -$messages['br'] = array( |
41 | | - 'mwe-loading_txt' => 'o kargañ...', |
42 | | - 'mwe-ok' => 'Mat eo', |
43 | | - 'mwe-cancel' => 'Nullañ', |
44 | | -); |
45 | | -$messages['bs'] = array( |
46 | | - 'mwe-loading_txt' => 'učitavam ...', |
47 | | - 'mwe-apiproxy-setup' => 'Postavljanje API proksija', |
48 | | - 'mwe-ok' => 'U redu', |
49 | | - 'mwe-cancel' => 'Odustani', |
50 | | -); |
51 | | -$messages['cs'] = array( |
52 | | - 'mwe-loading_txt' => 'Načítá se …', |
53 | | - 'mwe-cancel' => 'Storno', |
54 | | -); |
55 | | -$messages['cy'] = array( |
56 | | - 'mwe-loading_txt' => 'wrthi\'n llwytho ...', |
57 | | -); |
58 | | -$messages['de'] = array( |
59 | | - 'mwe-loading_txt' => 'lade …', |
60 | | - 'mwe-error_load_lib' => 'Fehler: JavaScript $1 war nicht abrufbar oder lässt $2 nicht zu', |
61 | | - 'mwe-apiproxy-setup' => 'API-Proxy-Konfiguration', |
62 | | - 'mwe-ok' => 'OK', |
63 | | - 'mwe-cancel' => 'Abbrechen', |
64 | | -); |
65 | | -$messages['diq'] = array( |
66 | | - 'mwe-loading_txt' => 'bar beno...', |
67 | | - 'mwe-error_load_lib' => 'xeta: $1 JavaScript re nêresiyeno ya zi pê $2yi şınasnaye niyo.', |
68 | | - 'mwe-apiproxy-setup' => 'proxyê APIyi eyar beno', |
69 | | - 'mwe-load-drag-item' => 'unsur bar beno', |
70 | | - 'mwe-ok' => 'temam', |
71 | | - 'mwe-cancel' => 'iptal', |
72 | | -); |
73 | | -$messages['dsb'] = array( |
74 | | - 'mwe-loading_txt' => 'zacytujo se ...', |
75 | | - 'mwe-error_load_lib' => 'Zmólka: JavaScript $1 njejo wótwołujobny był abo njedefiněrujo $2', |
76 | | - 'mwe-apiproxy-setup' => 'Proksy API zarědowaś', |
77 | | - 'mwe-load-drag-item' => 'Wlecony zapisk se zacytujo', |
78 | | - 'mwe-ok' => 'W pórědku', |
79 | | - 'mwe-cancel' => 'Pśetergnuś', |
80 | | -); |
81 | | -$messages['el'] = array( |
82 | | - 'mwe-loading_txt' => 'φόρτωση ...', |
83 | | -); |
84 | | -$messages['eo'] = array( |
85 | | - 'mwe-loading_txt' => 'ŝarĝante ...', |
86 | | - 'mwe-cancel' => 'Nuligi', |
87 | | -); |
88 | | -$messages['es'] = array( |
89 | | - 'mwe-loading_txt' => 'cargando ...', |
90 | | - 'mwe-load-drag-item' => 'Cargando el objeto arrastrado', |
91 | | - 'mwe-ok' => 'OK', |
92 | | - 'mwe-cancel' => 'Cancelar', |
93 | | -); |
94 | | -$messages['eu'] = array( |
95 | | - 'mwe-loading_txt' => 'Kargatzen ...', |
96 | | - 'mwe-ok' => 'Ados', |
97 | | - 'mwe-cancel' => 'Ezeztatu', |
98 | | -); |
99 | | -$messages['fi'] = array( |
100 | | - 'mwe-cancel' => 'Peruuta', |
101 | | -); |
102 | | -$messages['fr'] = array( |
103 | | - 'mwe-loading_txt' => 'chargement ...', |
104 | | - 'mwe-error_load_lib' => 'Erreur : JavaScript $1 n\'a pas pu être trouvé ou ne définit pas $2', |
105 | | - 'mwe-apiproxy-setup' => 'Configuration du proxy API', |
106 | | - 'mwe-load-drag-item' => 'Chargement de l’élément dépose', |
107 | | - 'mwe-ok' => 'OK', |
108 | | - 'mwe-cancel' => 'Annuler', |
109 | | -); |
110 | | -$messages['gl'] = array( |
111 | | - 'mwe-loading_txt' => 'cargando...', |
112 | | - 'mwe-error_load_lib' => 'Erro: o JavaScript $1 non se puido atopar ou non definía $2', |
113 | | - 'mwe-apiproxy-setup' => 'Configurando o proxy API', |
114 | | - 'mwe-load-drag-item' => 'Cargando o elemento arrastrado', |
115 | | - 'mwe-ok' => 'De acordo', |
116 | | - 'mwe-cancel' => 'Cancelar', |
117 | | -); |
118 | | -$messages['gsw'] = array( |
119 | | - 'mwe-loading_txt' => 'Am Lade ...', |
120 | | - 'mwe-error_load_lib' => 'Fähler: s JavaScript $1 het nit chenne glade wäre oder s losst $2 nit zue', |
121 | | - 'mwe-apiproxy-setup' => 'API-Proxy-Konfiguration', |
122 | | - 'mwe-load-drag-item' => 'Am Lade vu mitgschleipfte Poschte', |
123 | | - 'mwe-ok' => 'OK', |
124 | | - 'mwe-cancel' => 'Abbräche', |
125 | | -); |
126 | | -$messages['he'] = array( |
127 | | - 'mwe-loading_txt' => 'בטעינה ...', |
128 | | - 'mwe-error_load_lib' => 'שגיאה: לא ניתן היה לטעון את ספריית ה־JavaScript בשם $1 או שהיא אינה מגדירה את $2', |
129 | | -); |
130 | | -$messages['hsb'] = array( |
131 | | - 'mwe-loading_txt' => 'začituje so ...', |
132 | | - 'mwe-size-gigabytes' => '$1 GB', |
133 | | - 'mwe-size-megabytes' => '$1 MB', |
134 | | - 'mwe-size-kilobytes' => '$1 KB', |
135 | | - 'mwe-size-bytes' => '$1 B', |
136 | | - 'mwe-error_load_lib' => 'Zmylk: JavaScript $1 njeda so wotwołać abo njedefinuje $2', |
137 | | - 'mwe-apiproxy-setup' => 'Proksy API zarjadować', |
138 | | - 'mwe-load-drag-item' => 'Wlečeny zapisk so začituje', |
139 | | - 'mwe-ok' => 'W porjadku', |
140 | | - 'mwe-cancel' => 'Přetorhnyć', |
141 | | -); |
142 | | -$messages['hu'] = array( |
143 | | - 'mwe-loading_txt' => 'betöltés…', |
144 | | - 'mwe-error_load_lib' => 'Hiba: a(z) $1 JavaScript-fájl nem elérhető, vagy nem definiálja a(z) $2 osztályt.', |
145 | | - 'mwe-apiproxy-setup' => 'API proxy beállítása', |
146 | | - 'mwe-load-drag-item' => 'Vonszolt elem betöltése', |
147 | | - 'mwe-ok' => 'OK', |
148 | | - 'mwe-cancel' => 'Mégse', |
149 | | -); |
150 | | -$messages['ia'] = array( |
151 | | - 'mwe-loading_txt' => 'cargamento ...', |
152 | | - 'mwe-error_load_lib' => 'Error: JavaScript $1 non esseva recuperabile o non defini $2', |
153 | | - 'mwe-apiproxy-setup' => 'Configuration del proxy pro le API', |
154 | | - 'mwe-load-drag-item' => 'Cargamento del file trahite', |
155 | | - 'mwe-ok' => 'OK', |
156 | | - 'mwe-cancel' => 'Cancella', |
157 | | -); |
158 | | -$messages['id'] = array( |
159 | | - 'mwe-loading_txt' => 'memuat...', |
160 | | - 'mwe-error_load_lib' => 'Kesalahan: JavaScript $1 tidak dapat diambil atau tidak mendefinisikan $2', |
161 | | - 'mwe-apiproxy-setup' => 'Menyiapkan proksi API', |
162 | | - 'mwe-load-drag-item' => 'Memuat butir terseret', |
163 | | - 'mwe-ok' => 'Oke', |
164 | | - 'mwe-cancel' => 'Batalkan', |
165 | | -); |
166 | | -$messages['it'] = array( |
167 | | - 'mwe-cancel' => 'Annulla', |
168 | | -); |
169 | | -$messages['ja'] = array( |
170 | | - 'mwe-loading_txt' => '読み込み中 …', |
171 | | - 'mwe-error_load_lib' => 'エラー:JavaScript $1 は参照不能か、$2 を定義していません。', |
172 | | - 'mwe-apiproxy-setup' => 'API プロキシーをセットアップ中', |
173 | | - 'mwe-load-drag-item' => 'ドラッグされた項目を読み込み中', |
174 | | - 'mwe-ok' => 'OK', |
175 | | - 'mwe-cancel' => '中止', |
176 | | -); |
177 | | -$messages['ko'] = array( |
178 | | - 'mwe-loading_txt' => '불러오는 중...', |
179 | | - 'mwe-cancel' => '취소', |
180 | | -); |
181 | | -$messages['ksh'] = array( |
182 | | - 'mwe-loading_txt' => 'aam Laade …', |
183 | | - 'mwe-size-gigabytes' => '$1 GB', |
184 | | - 'mwe-size-megabytes' => '$1 MB', |
185 | | - 'mwe-size-kilobytes' => '$1 KB', |
186 | | - 'mwe-size-bytes' => '$1 Bytes', |
187 | | - 'mwe-error_load_lib' => 'Fähler: Dat JavaSkrep „<code lang="en">$1</code>“ wohr nit ze laade udder et leiht „<code lang="en">$2</code>“ nit faß.', |
188 | | - 'mwe-cancel' => 'Affbräsche', |
189 | | -); |
190 | | -$messages['lb'] = array( |
191 | | - 'mwe-loading_txt' => 'lueden ...', |
192 | | - 'mwe-apiproxy-setup' => 'API-Proxy astellen', |
193 | | - 'mwe-ok' => 'OK', |
194 | | - 'mwe-cancel' => 'Ofbriechen', |
195 | | -); |
196 | | -$messages['ml'] = array( |
197 | | - 'mwe-loading_txt' => 'ശേഖരിക്കുന്നു ...', |
198 | | - 'mwe-error_load_lib' => 'പിശക്: ജാവാസ്ക്രിപ്റ്റ് $1 ശേഖരിക്കാൻ കഴിഞ്ഞില്ല അല്ലെങ്കിൽ $2 നിർവ്വചിച്ചിട്ടില്ല', |
199 | | - 'mwe-apiproxy-setup' => 'എ.പി.ഐ. പ്രോക്സി സജ്ജീകരിക്കുക', |
200 | | - 'mwe-load-drag-item' => 'വലിച്ചിട്ടത് ശേഖരിക്കുന്നു', |
201 | | - 'mwe-ok' => 'ശരി', |
202 | | - 'mwe-cancel' => 'റദ്ദാക്കുക', |
203 | | -); |
204 | | -$messages['nl'] = array( |
205 | | - 'mwe-loading_txt' => 'bezig met laden ...', |
206 | | - 'mwe-error_load_lib' => 'Fout: JavaScript $1 kon niet opgehaald worden of definieert $2 niet', |
207 | | - 'mwe-apiproxy-setup' => 'Bezig met het opzetten van een API-proxy', |
208 | | - 'mwe-load-drag-item' => 'Bezig met het laden van het gesleepte bestand', |
209 | | - 'mwe-ok' => 'OK', |
210 | | - 'mwe-cancel' => 'Annuleren', |
211 | | -); |
212 | | -$messages['oc'] = array( |
213 | | - 'mwe-loading_txt' => 'cargament ...', |
214 | | - 'mwe-error_load_lib' => 'Error : JavaScript $1 a pas pogut èsser trobat o definís pas $2', |
215 | | - 'mwe-apiproxy-setup' => 'Configuracion del proxy API', |
216 | | - 'mwe-load-drag-item' => 'Cargament de l’element depausat', |
217 | | - 'mwe-ok' => 'OK', |
218 | | - 'mwe-cancel' => 'Anullar', |
219 | | -); |
220 | | -$messages['pdc'] = array( |
221 | | - 'mwe-ok' => 'OK', |
222 | | -); |
223 | | -$messages['pl'] = array( |
224 | | - 'mwe-loading_txt' => 'ładowanie ...', |
225 | | - 'mwe-error_load_lib' => 'Błąd – W plik JavaScript $1 brak jest możliwości pobrania oraz definicji $2', |
226 | | -); |
227 | | -$messages['pt'] = array( |
228 | | - 'mwe-loading_txt' => 'A carregar ...', |
229 | | - 'mwe-error_load_lib' => 'Erro: O JavaScript $1 não pode ser importado ou não define $2', |
230 | | - 'mwe-apiproxy-setup' => 'A preparar o \'\'proxy\'\' da API', |
231 | | - 'mwe-load-drag-item' => 'Carregando o objecto arrastado', |
232 | | - 'mwe-ok' => 'OK', |
233 | | - 'mwe-cancel' => 'Cancelar', |
234 | | -); |
235 | | -$messages['ru'] = array( |
236 | | - 'mwe-loading_txt' => 'загрузка …', |
237 | | - 'mwe-error_load_lib' => 'Ошибка. JavaScript $1 не доступен или не определяет $2', |
238 | | - 'mwe-apiproxy-setup' => 'Настройка API-прокси', |
239 | | - 'mwe-load-drag-item' => 'Загрузка перетащенного элемента', |
240 | | - 'mwe-ok' => 'OK', |
241 | | - 'mwe-cancel' => 'Отмена', |
242 | | -); |
243 | | -$messages['sk'] = array( |
244 | | - 'mwe-loading_txt' => 'načítava sa ...', |
245 | | - 'mwe-error_load_lib' => 'Error: JavaScript $1 nebolo možné získať alebo neobsahuje definíciu $2', |
246 | | -); |
247 | | -$messages['sv'] = array( |
248 | | - 'mwe-ok' => 'OK', |
249 | | - 'mwe-cancel' => 'Avbryt', |
250 | | -); |
251 | | -$messages['te'] = array( |
252 | | - 'mwe-ok' => 'సరే', |
253 | | - 'mwe-cancel' => 'రద్దుచేయి', |
254 | | -); |
255 | | -$messages['tr'] = array( |
256 | | - 'mwe-loading_txt' => 'yükleniyor ...', |
257 | | - 'mwe-error_load_lib' => 'Hata: $1 JavaScripti erişilebilir değil ya da $2 tanımlı değil', |
258 | | - 'mwe-apiproxy-setup' => 'API vekili ayarlanıyor', |
259 | | - 'mwe-load-drag-item' => 'Sürüklenen öğe yükleniyor', |
260 | | - 'mwe-ok' => 'Tamam', |
261 | | - 'mwe-cancel' => 'İptal', |
262 | | -); |
263 | | -$messages['vec'] = array( |
264 | | - 'mwe-loading_txt' => 'so\' drio cargar ...', |
265 | | - 'mwe-ok' => 'Va ben', |
266 | | - 'mwe-cancel' => 'Anula', |
267 | | -); |
268 | | -$messages['vi'] = array( |
269 | | - 'mwe-loading_txt' => 'đang tải …', |
270 | | - 'mwe-size-kilobytes' => '$1 kB', |
271 | | - 'mwe-ok' => 'OK', |
272 | | - 'mwe-cancel' => 'Hủy bỏ', |
273 | | -); |
Index: trunk/extensions/JS2Support/maintenance/MergeJavascriptMsg.php |
— | — | @@ -0,0 +1,136 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | +* Merges in JavaScript json msgs into respective module i18n.php file |
| 5 | +* |
| 6 | +* If your script uses JSON msg string with the This script helps merge msgs between javascript and php |
| 7 | +* |
| 8 | +* |
| 9 | +* @file |
| 10 | +* @ingroup Maintenance |
| 11 | +*/ |
| 12 | + |
| 13 | +# Abort if called from a web server |
| 14 | +if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) { |
| 15 | + print "This script must be run from the command line\n"; |
| 16 | + exit(); |
| 17 | +} |
| 18 | +// Change to the core maintenance script directory: |
| 19 | +require_once( dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' ); |
| 20 | + |
| 21 | + |
| 22 | +class MergeJavascriptMsg extends Maintenance { |
| 23 | + public function __construct() { |
| 24 | + parent::__construct(); |
| 25 | + $this->mDescription = "Merge Javascript JSON English messages to PHP"; |
| 26 | + } |
| 27 | + |
| 28 | + public function execute() { |
| 29 | + global $wgExtensionJavascriptLoader, $IP; |
| 30 | + foreach ( $wgExtensionJavascriptLoader as $loaderPath ){ |
| 31 | + |
| 32 | + $modulePath = dirname( $loaderPath ); |
| 33 | + $i18nFilePath = false; |
| 34 | + $moduleAbsoultePath = $IP ."/". $modulePath; |
| 35 | + |
| 36 | + // Look for the i18n.php file next to the loader |
| 37 | + if ( $handle = opendir( $moduleAbsoultePath ) ) { |
| 38 | + // Look for the i18n.php file |
| 39 | + while (false !== ($file = readdir($handle))) { |
| 40 | + if( substr( $file, -8 ) == 'i18n.php' ){ |
| 41 | + $i18nFilePath = $moduleAbsoultePath .'/'. $file; |
| 42 | + } |
| 43 | + } |
| 44 | + if( ! $i18nFilePath ) { |
| 45 | + $this->error( "Could not find i18n file in directory: $moduleAbsoultePath \n" ); |
| 46 | + } |
| 47 | + |
| 48 | + } else { |
| 49 | + $this->error( "Could not read path: $moduleAbsoultePath \n" ); |
| 50 | + } |
| 51 | + |
| 52 | + // Clear the local message var |
| 53 | + $this->messages = array(); |
| 54 | + |
| 55 | + // Load up the messages for the i18n file |
| 56 | + require_once( $i18nFilePath ); |
| 57 | + |
| 58 | + //Update the local messages var |
| 59 | + $this->messages = $messages['en']; |
| 60 | + |
| 61 | + // Recurse on every file in the module directory |
| 62 | + $objects = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $moduleAbsoultePath ), RecursiveIteratorIterator::SELF_FIRST ); |
| 63 | + foreach ( $objects as $fname => $object ) { |
| 64 | + $this->processFilePath( $fname ); |
| 65 | + } |
| 66 | + |
| 67 | + // Merge the msg back into the module php file |
| 68 | + $this->mergeModuleMsg( $i18nFilePath ); |
| 69 | + } |
| 70 | + } |
| 71 | + /** |
| 72 | + * mergeModuleMsg |
| 73 | + */ |
| 74 | + function mergeModuleMsg( $i18nFilePath ) { |
| 75 | + $mwSTART_MSG_KEY = '$messages[\'en\'] = array('; |
| 76 | + $mwEND_MSG_KEY = ', |
| 77 | +);'; |
| 78 | + |
| 79 | + $rawLangFile = file_get_contents( $i18nFilePath ); |
| 80 | + $startInx = strpos( $rawLangFile, $mwSTART_MSG_KEY ) + strlen( $mwSTART_MSG_KEY ); |
| 81 | + $endInx = strpos( $rawLangFile, $mwEND_MSG_KEY ) + 1; |
| 82 | + if ( $startInx === false || $endInx === false ) { |
| 83 | + $this->error( "Could not find $mwSTART_MSG_KEY or $mwEND_MSG_KEY in mwEmbed.i18n.php\n" ); |
| 84 | + } |
| 85 | + $preFile = substr( $rawLangFile, 0, $startInx ); |
| 86 | + $postFile = substr( $rawLangFile, $endInx ); |
| 87 | + |
| 88 | + $outPhp="\n"; |
| 89 | + foreach($this->messages as $msgKey => $msgValue ){ |
| 90 | + $outPhp .= "\t'{$msgKey}' => '" . str_replace( '\'', '\\\'', $msgValue ) . "',\n"; |
| 91 | + } |
| 92 | + // update the file and report progress |
| 93 | + file_put_contents( $i18nFilePath, $preFile . "\n\t". trim( $outPhp ) . $postFile ); |
| 94 | + $this->output( "Updated File: " . $i18nFilePath . "\n" ); |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Process a file path for msgs |
| 99 | + */ |
| 100 | + function processFilePath( $fname ){ |
| 101 | + // Only work on javascript files: |
| 102 | + if ( substr( $fname, - 3 ) != '.js' ){ |
| 103 | + return false; |
| 104 | + } |
| 105 | + $jsFileText = file_get_contents( $fname ); |
| 106 | + // Grab all the javascript msgs |
| 107 | + if ( preg_match( '/mw\.addMessages\s*\(\s*{(.*)}\s*\)\s*/siU', |
| 108 | + $jsFileText, |
| 109 | + $matches ) ) |
| 110 | + { |
| 111 | + $jsMsgs = json_decode( '{' . $matches[1] . '}', true ); |
| 112 | + // Merge into the English $messages var |
| 113 | + if( $jsMsgs ){ |
| 114 | + foreach( $jsMsgs as $msgKey => $msgValue ){ |
| 115 | + if( isset( $this->messages[$msgKey] ) && |
| 116 | + $this->messages[$msgKey] != $msgValue |
| 117 | + ) { |
| 118 | + $this->output( "Warning:: $msgKey does not match \nphp:" . |
| 119 | + $this->messages[$msgKey] . "\n != \njs:" . $msgValue . "\n\n"); |
| 120 | + |
| 121 | + // NOTE we could force merge from js here |
| 122 | + } else { |
| 123 | + $this->messages[ $msgKey ] = $msgValue; |
| 124 | + } |
| 125 | + } |
| 126 | + } else { |
| 127 | + $this->output( "Error could not decode json in $fname \n"); |
| 128 | + } |
| 129 | + } else { |
| 130 | + // skip file no msgs |
| 131 | + } |
| 132 | + // Check against module messages |
| 133 | + } |
| 134 | +} |
| 135 | + |
| 136 | +$maintClass = "MergeJavascriptMsg"; |
| 137 | +require_once( DO_MAINTENANCE ); |
Index: trunk/extensions/JS2Support/README |
— | — | @@ -1,10 +1,8 @@ |
2 | 2 | = JS2 Support Extension = |
3 | 3 | |
4 | | -The JS2 Support svn:externals hosts the mwEmbed library. svn does not support |
5 | | -svn:externals on files so mwEmbed.js and jsScriptLoader.php are symbolically linked in the |
6 | | -working directory and updates are manually committed to the JS2extension. |
| 4 | +The JS2 Support extension includes a ScriptLoader and associated javascript helper library. |
7 | 5 | |
8 | | -the js2-work branch has been depreciated. |
| 6 | +The js2-work branch has been depreciated. |
9 | 7 | |
10 | 8 | The stand-alone mwEmbed support contains all the the stand alone mwEmbed modules |
11 | 9 | and these core mwEmbed libraries. You can learn more about mwEmbed stand alone in |
— | — | @@ -20,10 +18,10 @@ |
21 | 19 | To add the base js2 library support simply add the following to your LocalSettings.php: |
22 | 20 | require_once( "$IP/extensions/JS2Support/JS2Support.php" ); |
23 | 21 | |
24 | | -By default js2 support groups script and css requests, disable script grouping for debugging set: |
| 22 | +By default js2 support groups script and css requests. To disable script grouping in your localSettings.php set: |
25 | 23 | $wgEnableScriptLoader = false; |
26 | 24 | |
27 | | -If you want a fresh copy of the scripts ( and to disable minification in when wgEnableScriptLoader= true you can set ) |
| 25 | +If you want a fresh copy of all the scripts ( and to disable minification in when wgEnableScriptLoader= true you can set ) |
28 | 26 | $wgDebugJavaScript = true; |
29 | 27 | |
30 | 28 | == LocalSettings.php to enable all js2 extensions == |
— | — | @@ -48,7 +46,7 @@ |
49 | 47 | To add a javascript or css to the named paths ( so that the script loader can load it by name ) |
50 | 48 | $wgScriptLoaderNamedPaths[ 'myExtension' ] = 'extensions/myExtension/myExtension.js'; |
51 | 49 | |
52 | | -Then in your php you can inclue your with the following line: |
| 50 | +Then in your php you can include your with the following line: |
53 | 51 | $wgOut->addScriptClass( 'myExtension' /* scriptloader named path */ , 'page'/* group bucket id */ ); |
54 | 52 | This lets you use the named-path for includes and gives you control over script grouping with the |
55 | 53 | grouping argument. If for example your script is included on a set of special pages then you could |
— | — | @@ -71,45 +69,54 @@ |
72 | 70 | == Using JS2 with JS-modules == |
73 | 71 | |
74 | 72 | JS Modules are reusable sets of javascript that can be dynamically configured, loaded and executed in |
75 | | -arbitrary javascript contexts. These libraries should have a clean separation of configuration, |
| 73 | +arbitrary application contexts. Javascript modules promote a clean separation of configuration, |
76 | 74 | interface, and application flow. These modules define relative paths for assets and can be hosted |
77 | | -inside extensions or optionally used in stand-alone javascript applications. They provide a means to cleanly |
78 | | -"embed" mediaWiki interfaces into application contexts. |
| 75 | +inside extensions or optionally used in stand-alone javascript interfaces. |
79 | 76 | |
80 | | -Examples include embedding a video player with timed text subtitles pulled from an external wiki, to |
81 | | -embedding a wikiEditor toolbar on a view page. The use of "loaders" enables dynamic packaging of |
82 | | -modules with the intent of avoiding multiple requests, at the cost of slightly larger server side cache of |
83 | | -combined resources. |
| 77 | +The use of "loaders" enables dynamic packaging of modules with the intent of avoiding multiple requests, |
| 78 | +for dynamically loaded interfaces. |
84 | 79 | |
85 | | -It enables the server to deliver static configuration files that drive interface customizations in |
| 80 | +JS2 enables the server to deliver static configuration files that drive interface customizations in |
86 | 81 | javascript rather than costly dynamically html output from php. |
87 | 82 | |
88 | | -== JS-module components == |
| 83 | +== JS Module Components == |
89 | 84 | |
90 | 85 | The three components of a js-module are "module loaders", "module activators" and "library code and assets". |
91 | 86 | |
92 | | -* "module loaders" build the request set of the javascript and css assets for a given interface "module" |
93 | | -in the context of user preferences or application configuration. |
| 87 | +* "module loaders" define named paths and build the request set of the javascript and css assets |
| 88 | +for a given interface "module". The set of requested libraries can driven by site configuration, |
| 89 | +and user preferences. The requested set of modules can include core libraries like jquery.ui helpers. |
94 | 90 | |
95 | | -* "module activators" call the module loaders in a given application context. For example |
96 | | -an edit page or a view page may call the wikiToolBar with different module configuration. |
| 91 | +* "module activators" Call the module loaders in a given application context and then |
| 92 | +invoke the interface or application. |
97 | 93 | |
98 | 94 | * "library code and assets" These consist of library code and assets that is the user interface or application. |
99 | | -These libs are driven by a given configuration. |
| 95 | +These libraries are driven by a given configuration. |
100 | 96 | |
101 | 97 | == Example Flow and File Contents == |
102 | 98 | |
103 | | -When an application wants to use that interface component it calls the module loader. |
104 | | -The module loader checks relevant configuration and javascript application state for existing |
105 | | -satisfied dependencies or browser specific libraries, then issues a single script-loader |
106 | | -request that retrieves all the needed javascript, css and localized message text for |
107 | | -that interface, the returned javascript will be minfied and gziped and cached on the server. |
| 99 | +When an application wants to use a interface component it calls the module loader from its activator. |
| 100 | +The module loader checks relevant configuration, it then issues a single script-loader |
| 101 | +request that checks javascript application state for existing satisfied dependencies or native browser support |
| 102 | +it then retrieves all the needed javascript, css and localized message text for that interface. |
| 103 | +The returned javascript will be minfied and gziped and cached on the server. |
| 104 | +The activator gets a callback that the interface library is loaded, and can then use that interface. |
108 | 105 | |
109 | | -Example loader.js: |
| 106 | +=== Example Loader loader.js: === |
110 | 107 | |
| 108 | +Loaders should define named class paths, named "module loader" functions and default configuration |
| 109 | +if appropriate. Style sheet assets should be named mw.style[ {styleName} ] this is so we can |
| 110 | +register the presence of style sheets in javascript and libraries can dynamically |
| 111 | +share style sheet components. |
| 112 | + |
111 | 113 | /* |
112 | 114 | * First we define the named script class paths |
113 | 115 | * Each class "mw.myJsModuleUI" defines its class name in the javascript |
| 116 | +* Note these named paths should be in "JSON" not javascript |
| 117 | +* The scriptLoader will parse these named paths. |
| 118 | +* |
| 119 | +* By putting these in javascript instead of php we can develop the library |
| 120 | +* in "raw" file mode ( by setting wgEnableScriptLoader = false ) |
114 | 121 | */ |
115 | 122 | mw.addClassFilePaths( { |
116 | 123 | "mw.myJsModuleHandler" : "js/mw.myJSModuleHandler.js", |
— | — | @@ -133,13 +140,14 @@ |
134 | 141 | $j( mw ).trigger( 'LoaderMyJsModuleAddFeatures', requestSet ); |
135 | 142 | |
136 | 143 | // Load the request set and run the ModuleLoader callback. |
137 | | - mw.load( requestSet, callback) |
| 144 | + mw.load( requestSet, callback ); |
138 | 145 | |
139 | 146 | }); |
140 | 147 | |
141 | | -Example "Activator" |
| 148 | +=== Example "Activator" MyModulePage.js === |
142 | 149 | /* |
143 | | -* Anytime we want to use the module we simply call the module loader |
| 150 | +* MyModulePage.js is included on pages that we want via normal php extension hooks. |
| 151 | +* Once we want to use the module we simply call the module loader |
144 | 152 | */ |
145 | 153 | var myModuleConfig = { |
146 | 154 | 'configOption1' : mw.getConfig( 'myJsModule.configOption1' ) |
— | — | @@ -153,46 +161,76 @@ |
154 | 162 | $j('#targetElement').myJsModule( myModuleConfig ); |
155 | 163 | } |
156 | 164 | |
157 | | -Example Library Code |
| 165 | +=== Example Library Code === |
158 | 166 | |
159 | 167 | The key thing to remember about library code is that it defines a named class ie: |
160 | | -mw.load( 'mw.Foo' ... |
161 | | -// will load a file that includes |
162 | | -mw.Foo = function(){ ... |
| 168 | +a file by name 'mw.Foo.js' would define a object named 'mw.Foo' ie something like: |
| 169 | + |
| 170 | +mw.Foo = function( options ){ |
| 171 | + this.init( options ); |
| 172 | +} |
163 | 173 | |
| 174 | +mw.Foo.prototype = { |
| 175 | + 'init' : function(){ /* constructor */ } |
| 176 | + 'drawUI' : function(){ ... } |
| 177 | +} |
| 178 | + |
164 | 179 | Library code should operate off of global configuration mw.getConfig( 'configurationOption' ) |
165 | 180 | and or local configuration ( where appropriate ) ie the constructor gets passed an options object |
166 | 181 | that defines named value pairs of configuration or callbacks. |
167 | 182 | |
| 183 | +The other key thing to remember about library code is to handle localization in some way. |
| 184 | +The localization options are presented bellow |
| 185 | + |
168 | 186 | == Localization == |
169 | 187 | |
170 | | -The JS2 Localization system works similar to its php counterpart. |
171 | | -( it includes support for {{PLURAL}} transforms ) |
| 188 | +Each javascript module hosts a {moduleName}.i18n.php file that works with the |
| 189 | +existing mediaWiki translate system. Note when the script-loader populates |
| 190 | +the msg replacements it uses mediaWiki's wfGetMsg function so any database |
| 191 | +MediaWiki namespace strings ''will be'' included in your javascript messages. |
172 | 192 | |
173 | | -To get a msg simply issue the call: |
174 | | -gM( 'msg-key', 'replacement1', 'replacement2', 'etc' ); |
| 193 | +You have three options for packaging messages in your javascript module |
175 | 194 | |
176 | | -Note you can pass jQuery replacements in the case of links ie: |
177 | | -gM( 'msg-key', $j('<a />').text( gM( 'link-text' ) ); |
| 195 | +1) If your javascript module is simple and your interface is mostly set in a single |
| 196 | +file you may want to load all your msgs at once. You can get all the msgs in your javascript |
| 197 | +module's localization file by simply isssuing the call: |
| 198 | +mw.includeAllModuleMsgs(); |
178 | 199 | |
179 | | -For full documentation see: mwEmbed/languages/mw.Language.js function: mw.getMsg |
| 200 | +Putting this function call at the top of your primary library code javascript file will be |
| 201 | +replaced with all the msgs in your modules php localization file in the current language. |
180 | 202 | |
| 203 | +2 ) If your code includes many sub-modules and you may want fine grain control over what msgs |
| 204 | +are packaged when. You can define the set of msg keys it at the top of any javascript file. |
181 | 205 | |
182 | | -If you want ~all~ of the msgs for your module php localization file you can simply issue |
183 | | -a call mw.includeAllMsgs() near the top of your primary library code. This will |
184 | | -include be replaced with all the msgs in your php localization file for your selected language. |
| 206 | +For example: |
| 207 | +mw.addMessegeKeys( ['list', 'of', 'msg-keys' ] ); |
185 | 208 | |
186 | | -If your code includes many sub-modules and you want fine grain control over what msgs |
187 | | -are packaged when you can define the set of msg keys it at the top of any javascript file. |
| 209 | +Will be replaced by the script-loader with the localized msgs for every listed key. |
| 210 | + |
| 211 | +3) If you are doing a lot of stand alone testing it can be faster to use a json array |
| 212 | +at the top of your javascript file. |
| 213 | +mw.addMesseges( { "msg-key" : "English fallback" } ); |
188 | 214 | |
189 | | -You can use a list of keys: |
| 215 | + Your javascript file then becomes your developer reference English messages. A maintenance scripts then |
| 216 | +copy your English fallbacks into the php localization file for the translate wiki scripts to work with. |
| 217 | +Running the JS2Support maintenance script "mergeJavascriptMsgs.php" will sync javascript into phpt files. |
190 | 218 | |
191 | | -mw.addMessegeKeys( ['list', 'of', 'msg-keys' ] ); |
| 219 | +This is the most complicated setup, if your unsure use the first option: |
| 220 | +mw.includeAllModuleMsgs(); |
| 221 | + |
| 222 | +=== Accessing Msgs in Javascript === |
192 | 223 | |
193 | | -or if you are doing a lot of stand alone testing it can be faster and simpler to use a json array: |
194 | | -mw.addMesseges( { "msg-key" : "english fallback" } ); |
| 224 | +The JS2 Localization system works similar to its php counterpart. It includes |
| 225 | +support for {{PLURAL}} transforms. |
195 | 226 | |
196 | | -Either way the set of messages will be localized by the scriptLoader once the javascript class is requested. |
| 227 | +To get a message simply issue the call: |
| 228 | +gM( 'msg-key', 'replacement1', 'replacement2', 'etc' ); |
197 | 229 | |
| 230 | +Note you can pass jQuery replacements in the case of links ie: |
| 231 | +gM( 'msg-key', $j('<a />').text( gM( 'link-text' ) ); |
198 | 232 | |
| 233 | +For full documentation see: mwEmbed/languages/mw.Language.js function: mw.getMsg |
199 | 234 | |
| 235 | + |
| 236 | + |
| 237 | + |