r35886 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35885‎ | r35886 | r35887 >
Date:21:54, 4 June 2008
Author:kim
Status:old
Tags:
Comment:
i18n stage 1, now to actually get users their preferred language at login
Modified paths:
  • /trunk/extensions/Wikidata/util/voctrain/i18n (added) (history)
  • /trunk/extensions/Wikidata/util/voctrain/i18n/Names.php (added) (history)
  • /trunk/extensions/Wikidata/util/voctrain/i18n/Names_wiki.php (added) (history)
  • /trunk/extensions/Wikidata/util/voctrain/i18n/language.php (added) (history)
  • /trunk/extensions/Wikidata/util/voctrain/i18n/messages (added) (history)
  • /trunk/extensions/Wikidata/util/voctrain/i18n/messages/Messages_Default.php (added) (history)
  • /trunk/extensions/Wikidata/util/voctrain/i18n/messages/Messages_eng.php (added) (history)
  • /trunk/extensions/Wikidata/util/voctrain/i18n/messages/Messages_nld.php (added) (history)
  • /trunk/extensions/Wikidata/util/voctrain/i18n/messages/Messages_nld.php.old (added) (history)
  • /trunk/extensions/Wikidata/util/voctrain/view.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/util/voctrain/i18n/messages/Messages_Default.php
@@ -0,0 +1,7 @@
 2+<?php
 3+
 4+$fallback=false;
 5+
 6+require_once("Messages_eng.php");
 7+
 8+?>
Index: trunk/extensions/Wikidata/util/voctrain/i18n/messages/Messages_eng.php
@@ -0,0 +1,55 @@
 2+<?php
 3+
 4+$fallback=false;
 5+
 6+#do not translate words starting with '%' (ie %action myst
 7+
 8+$messages=array(
 9+ "Hello World"=>"HELLO WIKI!",
 10+ "Permission Denied"=>"Permission Denied",
 11+ "try again?"=>"try again?",
 12+ "Action unknown"=>"Action unknown",
 13+ "I don't know what to do with '%action'." =>
 14+ "I don't know what to do with '%action'.",
 15+ "User added" => "User added",
 16+ "Hello, %username, welcome to the omega language trainer" =>
 17+ "Hello, %username, welcome to the omega language trainer",
 18+ "continue"=>"continue",
 19+ "hello %place"=>"hello there %place",
 20+ "bye"=>"goodbye",
 21+ "Set up your exercise"=>"Set up your exercise",
 22+ "Number of questions"=>"Number of questions",
 23+ "Languages"=>"Languages",
 24+ "Please specify the languages you want to test in"=>"Please specify the languages you want to test in",
 25+ "(eg, eng for English, deu for Deutch (German))."=>"(eg, eng for English, deu for Deutch (German)).",
 26+ "Depending on your test set, some combinations might work better than others."=>"Depending on your test set, some combinations might work better than others.",
 27+ "Questions"=>"Questions",
 28+ "Answers"=>"Answers",
 29+ "start exercise"=>"start exercise",
 30+ "collection"=>"collection",
 31+ "ISO-639-3 format"=>"ISO-639-3 format",
 32+ "There are %questions_remaining questions remaining, out of a total of %questions_total."=>"There are %questions_remaining questions remaining, out of a total of %questions_total.",
 33+ "Definition"=>"Definition",
 34+ "Dictionary definition to help you"=>"Dictionary definition to help you",
 35+ "Word"=>"Word",
 36+ "Please type your answer here"=>"Please type your answer here",
 37+ "submit answer"=>"submit answer",
 38+ "peek"=>"peek",
 39+ "skip"=>"skip",
 40+ "I know it/do not ask again"=>"I know it/do not ask again",
 41+ "abort exercise"=>"abort exercise",
 42+ "list answers"=>"list answers",
 43+ "Question"=>"Question",
 44+ "The word to translate"=>"The word to translate",
 45+ "Answer"=>"Answer",
 46+ "one of"=>"one of",
 47+ "list of questions and answers"=>"list of questions and answers",
 48+ "Answer(s)"=>"Answer(s)",
 49+ "logout"=>"logout",
 50+ "Powered by"=>"Powered by",
 51+ "Omegawiki"=>"Omegawiki",
 52+ "Exercise complete"=>"Exercise complete",
 53+ "Exercise terminated"=>"Exercise terminated",
 54+ "Start a new exercise"=>"Start a new exercise"
 55+ );
 56+?>
Index: trunk/extensions/Wikidata/util/voctrain/i18n/messages/Messages_nld.php.old
@@ -0,0 +1,9 @@
 2+<?php
 3+
 4+$fallback="eng";
 5+
 6+$messages=array(
 7+ "Hello World"=>"Hallo Wereld!",
 8+ "farewell"=>"vaarwel"
 9+)
 10+?>
Index: trunk/extensions/Wikidata/util/voctrain/i18n/messages/Messages_nld.php
@@ -0,0 +1,53 @@
 2+<?php
 3+
 4+$fallback=false;
 5+
 6+$messages=array(
 7+ "Hello World"=>"HALLO WIKI!",
 8+ "Permission Denied"=>"Toestemming Geweigerd",
 9+ "try again?"=>"probeer opnieuw?",
 10+ "Action unknown"=>"Action onbekend",
 11+ "I don't know what to do with '%action'." =>
 12+ "Ik don't know what to do with '%action'.",
 13+ "User added" => "User added",
 14+ "Hello, %username, welcome to the omega language trainer" =>
 15+ "Hello, %username, welcome to the omega language trainer",
 16+ "continue"=>"continue",
 17+ "hello %place"=>"hello there %place",
 18+ "bye"=>"goodbye",
 19+ "Set up your exercise"=>"Set up your exercise",
 20+ "Number of questions"=>"Number of questions",
 21+ "Languages"=>"Languages",
 22+ "Please specify the languages you want to test in"=>"Please specify the languages you want to test in",
 23+ "(eg, eng for English, deu for Deutch (German))."=>"(eg, eng for English, deu for Deutch (German)).",
 24+ "Depending on your test set, some combinations might work better than others."=>"Depending on your test set, some combinations might work better than others.",
 25+ "Questions"=>"Questions",
 26+ "Answers"=>"Answers",
 27+ "start exercise"=>"start exercise",
 28+ "collection"=>"collection",
 29+ "ISO-639-3 format"=>"ISO-639-3 format",
 30+ "There are %questions_remaining questions remaining, out of a total of %questions_total."=>"There are %questions_remaining questions remaining, out of a total of %questions_total.",
 31+ "Definition"=>"Definition",
 32+ "Dictionary definition to help you"=>"Dictionary definition to help you",
 33+ "Word"=>"Word",
 34+ "Please type your answer here"=>"Please type your answer here",
 35+ "submit answer"=>"submit answer",
 36+ "peek"=>"peek",
 37+ "skip"=>"skip",
 38+ "I know it/do not ask again"=>"I know it/do not ask again",
 39+ "abort exercise"=>"abort exercise",
 40+ "list answers"=>"list answers",
 41+ "Question"=>"Question",
 42+ "The word to translate"=>"The word to translate",
 43+ "Answer"=>"Answer",
 44+ "one of"=>"one of",
 45+ "list of questions and answers"=>"list of questions and answers",
 46+ "Answer(s)"=>"Answer(s)",
 47+ "logout"=>"logout",
 48+ "Powered by"=>"Powered by",
 49+ "Omegawiki"=>"Omegawiki",
 50+ "Exercise complete"=>"Exercise complete",
 51+ "Exercise terminated"=>"Exercise terminated",
 52+ "Start a new exercise"=>"Start a new exercise"
 53+ );
 54+?>
Index: trunk/extensions/Wikidata/util/voctrain/i18n/Names.php
@@ -0,0 +1,12 @@
 2+<?php
 3+
 4+
 5+# iso 693_3 language names
 6+
 7+$languageNames=array(
 8+ 'eng'=>'English',
 9+ 'nld'=>'Nederlands',
 10+ 'deu'=>'Deutch'
 11+)
 12+
 13+?>
Index: trunk/extensions/Wikidata/util/voctrain/i18n/language.php
@@ -0,0 +1,177 @@
 2+<?php
 3+
 4+class LocalisationException extends Exception {};
 5+class NoSuchMessageFileException extends LocalisationException {};
 6+
 7+/**loosely inspired on class of same name from mediawiki.
 8+* (mediawiki version is overkill for our purposes though)
 9+* also, unlike mediawiki, we always use ISO 639-3 for language codes.
 10+*/
 11+class Language {
 12+
 13+ private $code; #language code, mostly for debugging purposes
 14+ private $messages;
 15+ private $fallback=false;
 16+
 17+ public function __construct($code=null) {
 18+ $this->code=$code;
 19+ if ($code)
 20+ $this->loadMessages($code);
 21+
 22+ }
 23+
 24+ public function loadMessages($code="Default") {
 25+ $messages="Messages_$code.php";
 26+ $path=dirname(__FILE__)."/messages/$messages";
 27+ if (file_exists($path)) {
 28+ include($path);
 29+ if (isset($messages)) {
 30+ $this->messages=$messages; #messages is from the included file
 31+ } else {
 32+ throw new LocalisationException("messages file format problem, there's no $messages");
 33+ }
 34+
 35+ if (isset($fallback)) {
 36+ if ($fallback===false) {
 37+ $this->fallback=false;
 38+ } else {
 39+ $this->fallback=new Language($fallback);
 40+ }
 41+ }
 42+
 43+ } elseif ($code!=="Default") { #last dutch fallbacsk
 44+ $code="Default";
 45+ $this->loadMessages("Default");
 46+ } else {
 47+ throw new NoSuchMessageFileException("Could not find message file for language code '$code'; file '$path' does not exist");
 48+ }
 49+ $this->code=$code;
 50+ }
 51+
 52+ /**
 53+ * Get language names available for i18n, indexed by code.
 54+ * If $customisedOnly is true, only returns codes with a messages file
 55+ * modified from mediawiki (GPL applies)
 56+ */
 57+ public static function getI18NLanguageNames() {
 58+
 59+ $languageNames=Language::getAllLanguageNames();
 60+
 61+ $messageFiles = glob( dirname(__FILE__)."/messages/Messages_*.php" );
 62+ var_dump($messageFiles);
 63+ $names = array();
 64+ foreach ( $messageFiles as $file ) {
 65+ $m = array();
 66+ if( preg_match( '/Messages_([a-z_]+)\.php$/', $file, $m ) ) {
 67+ $code = str_replace( '_', '-', strtolower( $m[1] ) );
 68+ var_dump($code);
 69+ if ( isset( $languageNames[$code] ) ) {
 70+ $names[$code] = $languageNames[$code];
 71+ }
 72+ }
 73+ }
 74+ return $names;
 75+ }
 76+
 77+ public function translation_exists($phrase) {
 78+ if ($this->messages) {
 79+ return array_key_exists($phrase, $this->messages);
 80+ } else {
 81+ throw new Exception("not initialized, code ".$this->code);
 82+ }
 83+ }
 84+
 85+ /** translate the phrase, but doesn't do any substitutions. use printf,sprintf, or vsprintf for that */
 86+ public function translate($phrase) {
 87+ if ($this->translation_exists($phrase)) {
 88+ return $this->messages[$phrase];
 89+ } elseif ($this->fallback && $this->fallback->translation_exists($phrase)) {
 90+ return $this->fallback->translate($phrase);
 91+ } else {
 92+ return "{untranslated: '$phrase'}";
 93+ }
 94+ }
 95+
 96+
 97+ # == Diverse sprintf-ish functions
 98+
 99+ /** i18nsprint is a simpler way to go about things, will do i18n replacement
 100+ on antyhing enclosed in <| |>, any %signs in these substrings
 101+ will be substituted with items from the array*/
 102+ public function i18nsprint($string, $replacements=array()) {
 103+ $callback=new I18Ncallback();
 104+ $callback->replacements=$replacements;
 105+ $callback->language=$this;
 106+ return preg_replace_callback("#(?U)(<\|.*\|>)#", array($callback,"replace"), $string);
 107+ }
 108+
 109+ /* like i18nsprint, but prints directly to output*/
 110+ public function i18nprint($string, $replacements=array()) {
 111+ print $this->i18nsprint($string, $replacements);
 112+ }
 113+
 114+
 115+ public function printf($phrase) {
 116+ $args=func_get_args();
 117+ $str=$this->vsprintf($phrase, $args);
 118+ print $str;
 119+ return strlen($str);
 120+ }
 121+
 122+ # internationalized sprintf
 123+ public function sprintf($phrase) {
 124+ $args=func_get_args();
 125+ return $this->vsprintf($phrase, $args);
 126+ }
 127+
 128+ # internationalized vprintf
 129+ public function vsprintf($phrase, $array) {
 130+ return vsprintf($this->translate($phrase),$array);
 131+ }
 132+
 133+ /** assoc variant on vsprintf,
 134+ * (modified from sprintf2 by "matt", 10-Mar-2008 06:13,
 135+ * http://nl2.php.net/manual/en/function.sprintf.php )
 136+ * original Apparently Copyright © 2001-2008 The PHP Group, copied here
 137+ * on condition that copyright notice is retained. )
 138+ */
 139+ function vsprintf2($phrase='', $vars=array(), $char='%') {
 140+ $str=$this->translate($phrase);
 141+ if (!$str) return '';
 142+ if (count($vars) > 0) {
 143+ foreach ($vars as $k => $v) {
 144+ $str = str_replace($char . $k, $v, $str);
 145+ }
 146+ }
 147+
 148+ return $str;
 149+ }
 150+
 151+ # == Getters/setters
 152+
 153+ /**@return iso693_3 3-letter language code, or "Default".*/
 154+ public function getCode() {
 155+ return $this->code;
 156+ }
 157+
 158+ /** @return all possible languages indexed by code */
 159+ public static function getAllLanguageNames() {
 160+ include("Names.php");
 161+ return $languageNames;
 162+ }
 163+
 164+}
 165+
 166+
 167+/** for use by Language::i18nprint */
 168+class I18Ncallback {
 169+ public $language;
 170+ public $replacements;
 171+ public function replace($matches) {
 172+ $match=substr($matches[0],2,-2);
 173+
 174+ return $this->language->vsprintf2($match,$this->replacements);
 175+ }
 176+}
 177+
 178+?>
Index: trunk/extensions/Wikidata/util/voctrain/i18n/Names_wiki.php
@@ -0,0 +1,286 @@
 2+<?php
 3+/**
 4+ * @addtogroup Language
 5+ */
 6+$languageNames = array(
 7+ 'aa' => 'Afar', # Afar
 8+ 'ab' => 'Аҧсуа', # Abkhaz, should possibly add ' бысжѡа'
 9+ 'af' => 'Afrikaans', # Afrikaans
 10+ 'ak' => 'Akana', # Akan
 11+ 'als' => 'Alemannisch', # Alemannic -- not a valid code, for compatibility
 12+ 'am' => 'አማርኛ', # Amharic
 13+ 'an' => 'Aragonés', # Aragonese
 14+ 'ang' => 'Anglo Saxon', # Old English
 15+ 'ar' => 'العربية', # Arabic
 16+ 'arc' => 'ܕܥܒܪܸܝܛ', # Aramaic
 17+ 'as' => 'অসমীয়া', # Assamese
 18+ 'ast' => 'Asturianu', # Asturian
 19+ 'av' => 'Авар', # Avar
 20+ 'ay' => 'Aymar', # Aymara, should possibly be Aymará
 21+ 'az' => 'Azərbaycan', # Azerbaijani
 22+ 'ba' => 'Башҡорт', # Bashkir
 23+ 'bar' => 'Boarisch', # Bavarian (Austro-Bavarian and South Tyrolean)
 24+ 'bat-smg' => 'Žemaitėška', # Samogitian
 25+ 'be' => 'Беларуская', # Belarusian ''or'' Byelarussian
 26+ 'bg' => 'Български', # Bulgarian
 27+ 'bh' => 'भोजपुरी', # Bihara
 28+ 'bi' => 'Bislama', # Bislama
 29+ 'bm' => 'Bamanankan', # Bambara
 30+ 'bn' => 'বাংলা', # Bengali
 31+ 'bo' => 'བོད་ཡིག', # Tibetan
 32+ 'bpy' => 'ইমার ঠার/বিষ্ণুপ্রিয়া মণিপুরী', # Bishnupriya Manipuri
 33+ 'br' => 'Brezhoneg', # Breton
 34+ 'bs' => 'Bosanski', # Bosnian
 35+ 'bug' => 'ᨅᨔ ᨕᨘᨁᨗ', # Buginese
 36+ 'bxr' => 'Буряад', # Buryat (Russia)
 37+ 'ca' => 'Català', # Catalan
 38+ 'cbk-zam' => 'Zamboangueño', # Zamboanga Chavacano
 39+ 'cdo' => 'Mìng-dĕ̤ng-ngṳ̄', # Min Dong
 40+ 'ce' => 'Нохчийн', # Chechen
 41+ 'ceb' => 'Cebuano', # Cebuano
 42+ 'ch' => 'Chamoru', # Chamorro
 43+ 'cho' => 'Choctaw', # Choctaw
 44+ 'chr' => 'ᏣᎳᎩ', # Cherokee
 45+ 'chy' => 'Tsetsêhestâhese', # Cheyenne
 46+ 'co' => 'Corsu', # Corsican
 47+ 'cr' => 'Nēhiyaw / ᓀᐦᐃᔭᐤ', # Cree
 48+ 'crh' => 'Qırımtatarca', # Crimean Tatar
 49+ 'crh-latn' => 'Qırımtatarca (Latin)', # Crimean Tatar (Latin)
 50+ 'crh-cyrl' => 'Qırımtatarca (Kiril)', # Crimean Tatar (Cyrillic)
 51+ 'cs' => 'Česky', # Czech
 52+ 'csb' => 'Kaszëbsczi', # Cassubian
 53+ 'cu' => 'Словѣньскъ', # Old Church Slavonic (ancient language)
 54+ 'cv' => 'Чăвашла', # Chuvash
 55+ 'cy' => 'Cymraeg', # Welsh
 56+ 'da' => 'Dansk', # Danish
 57+ 'de' => 'Deutsch', # German
 58+ 'diq' => 'Zazaki', # Zazaki
 59+ 'dk' => 'Dansk', # Unused code currently redirecting to Danish, 'da' is correct for the language
 60+ 'dv' => 'ދިވެހިބަސް', # Dhivehi
 61+ 'dz' => 'ཇོང་ཁ', # Bhutani
 62+ 'ee' => 'Eʋegbe', # Ewe
 63+ 'el' => 'Ελληνικά', # Greek
 64+ 'eml' => 'Emiliàn e rumagnòl', # Emilian-Romagnol / Sammarinese
 65+ 'en' => 'English', # English
 66+ 'eo' => 'Esperanto', # Esperanto
 67+ 'es' => 'Español', # Spanish
 68+ 'et' => 'Eesti', # Estonian
 69+ 'eu' => 'Euskara', # Basque
 70+ 'fa' => 'فارسی', # Persian
 71+ 'ff' => 'Fulfulde', # Fulah
 72+ 'fi' => 'Suomi', # Finnish
 73+ 'fiu-vro' => 'Võro', # Võro
 74+ 'fj' => 'Na Vosa Vakaviti', # Fijian
 75+ 'fo' => 'Føroyskt', # Faroese
 76+ 'fr' => 'Français', # French
 77+ 'frp' => 'Arpitan', # Franco-Provençal/Arpitan
 78+ 'fur' => 'Furlan', # Friulian
 79+ 'fy' => 'Frysk', # Frisian
 80+ 'ga' => 'Gaeilge', # Irish
 81+ 'gd' => 'Gàidhlig', # Scots Gaelic
 82+ 'gl' => 'Galego', # Gallegan
 83+ 'glk' => 'گیلکی', # Gilaki
 84+ 'gn' => 'Avañe\'ẽ', # Guarani
 85+ 'got' => '𐌲𐌿𐍄𐌹𐍃𐌺', # Gothic
 86+ 'gsw' => 'Alemannisch', # Alemannic
 87+ 'gu' => 'ગુજરાતી', # Gujarati
 88+ 'gv' => 'Gaelg', # Manx
 89+ 'ha' => 'هَوُسَ', # Hausa
 90+ 'haw' => 'Hawai`i', # Hawaiian
 91+ 'he' => 'עברית', # Hebrew
 92+ 'hi' => 'हिन्दी', # Hindi
 93+ 'hil' => 'Ilonggo', # Hiligaynon
 94+ 'ho' => 'Hiri Motu', # Hiri Motu
 95+ 'hr' => 'Hrvatski', # Croatian
 96+ 'hsb' => 'Hornjoserbsce', # Upper Sorbian
 97+ 'ht' => 'Krèyol ayisyen', # Haitian, common/popular form is Kreyòl
 98+ 'hu' => 'Magyar', # Hungarian
 99+ 'hy' => 'Հայերեն', # Armenian
 100+ 'hz' => 'Otsiherero', # Herero
 101+ 'ia' => 'Interlingua', # Interlingua (IALA)
 102+ 'id' => 'Bahasa Indonesia', # Indonesian
 103+ 'ie' => 'Interlingue', # Interlingue (Occidental)
 104+ 'ig' => 'Igbo', # Igbo
 105+ 'ii' => 'ꆇꉙ', # Sichuan Yi
 106+ 'ik' => 'Iñupiak', # Inupiak
 107+ 'ilo' => 'Ilokano', # Ilokano
 108+ 'io' => 'Ido', # Ido
 109+ 'is' => 'Íslenska', # Icelandic
 110+ 'it' => 'Italiano', # Italian
 111+ 'iu' => 'ᐃᓄᒃᑎᑐᑦ', # Inuktitut
 112+ 'ja' => '日本語', # Japanese
 113+ 'jbo' => 'Lojban', # Lojban
 114+ 'jv' => 'Basa Jawa', # Javanese
 115+ 'ka' => 'ქართული', # Georgian
 116+ 'kaa' => 'Qaraqalpaqsha', # Karakalpak
 117+ 'kab' => 'ثاقبايليث', # Kabyle
 118+ 'kg' => 'Kongo', # Kongo, (FIXME!) should probaly be KiKongo or KiKoongo
 119+ 'ki' => 'Gĩkũyũ', # Kikuyu, correctness not guaranteed
 120+ 'kj' => 'Kuanyama', # Kuanyama (FIXME!)
 121+ 'kk' => 'Қазақша', # Kazakh
 122+ 'kk-cn' => 'قازاقشا (تٴوتە)', # Kazakh Arabic
 123+ 'kk-kz' => 'Қазақша (кирил)', # Kazakh Cyrillic
 124+ 'kk-tr' => 'Qazaqşa (latın)', # Kazakh Latin
 125+ 'kl' => 'Kalaallisut', # Greenlandic
 126+ 'km' => 'ភាសាខ្មែរ', # Cambodian
 127+ 'kn' => 'ಕನ್ನಡ', # Kannada
 128+ 'ko' => '한국어', # Korean
 129+ 'kr' => 'Kanuri', # Kanuri (FIXME!)
 130+ 'ks' => 'कश्मीरी - (كشميري)', # Kashmiri
 131+ 'ksh' => 'Ripoarisch', # Ripuarian
 132+ 'ku' => 'Kurdî / كوردي', # Kurdish
 133+ 'kv' => 'Коми', # Komi, cyrillic is common script but also written in latin script
 134+ 'kw' => 'Kernewek', # Cornish
 135+ 'ky' => 'Кыргызча', # Kirghiz
 136+ 'la' => 'Latina', # Latin
 137+ 'lad' => 'Ladino', # Ladino
 138+ 'lbe' => 'Лакку', # Lak
 139+ 'lb' => 'Lëtzebuergesch', # Luxemburguish
 140+ 'lg' => 'Luganda', # Ganda
 141+ 'li' => 'Limburgs', # Limburgian
 142+ 'lij' => 'Líguru', # Ligurian
 143+ 'lld' => 'Ladin', # Ladin
 144+ 'lmo' => 'Lumbaart', # Lombard
 145+ 'ln' => 'Lingála', # Lingala
 146+ 'lo' => 'ລາວ',# Laotian
 147+ 'lt' => 'Lietuvių', # Lithuanian
 148+ 'lv' => 'Latviešu', # Latvian
 149+ 'lzz' => 'Lazuri Nena', #Laz
 150+ 'map-bms' => 'Basa Banyumasan', # Banyumasan
 151+ 'mg' => 'Malagasy', # Malagasy
 152+ 'mh' => 'Ebon', # Marshallese
 153+ 'mi' => 'Māori', # Maori
 154+ 'minnan' => 'Bân-lâm-gú', # Min-nan (also zh-min-nan)
 155+ 'mk' => 'Македонски', # Macedonian
 156+ 'ml' => 'മലയാളം', # Malayalam
 157+ 'mn' => 'Монгол', # Mongoloian
 158+ 'mo' => 'Молдовеняскэ', # Moldovan
 159+ 'mr' => 'मराठी', # Marathi
 160+ 'ms' => 'Bahasa Melayu', # Malay
 161+ 'mt' => 'Malti', # Maltese
 162+ 'mus' => 'Muscogee', # Creek, should possibly be Muskogee
 163+ 'my' => 'Myanmasa', # Burmese
 164+ 'mzn' => 'مَزِروني', # Mazandarin
 165+ 'na' => 'Ekakairũ Naoero', # Nauruan
 166+ 'nah' => 'Nahuatl', # Nahuatl, en:Wikipedia writes Nahuatlahtolli, while another form is Náhuatl
 167+ 'nan' => 'Bân-lâm-gú', # Min-nan -- (bug 8217) nan instead of zh-min-nan, http://www.sil.org/iso639-3/codes.asp?order=639_3&letter=n
 168+ 'nap' => 'Nnapulitano', # Neapolitan
 169+ 'nb' => 'Norsk (bokmål)', # Norwegian (Bokmal)
 170+ 'nds' => 'Plattdüütsch', # Low German ''or'' Low Saxon
 171+ 'nds-nl' => 'Nedersaksisch', # Dutch Low Saxon
 172+ 'ne' => 'नेपाली', # Nepali
 173+ 'new' => 'नेपाल भाषा', # Newar / Nepal Bhasa
 174+ 'ng' => 'Oshiwambo', # Ndonga
 175+ 'nl' => 'Nederlands', # Dutch
 176+ 'nn' => 'Norsk (nynorsk)' , # Norwegian (Nynorsk)
 177+ 'no' => 'Norsk (bokmål)', # Norwegian
 178+ 'non' => 'Norrǿna', # Old Norse
 179+ 'nov' => 'Novial', # Novial
 180+ 'nrm' => 'Nouormand', # Norman
 181+ 'nv' => 'Diné bizaad', # Navajo
 182+ 'ny' => 'Chi-Chewa', # Chichewa
 183+ 'oc' => 'Occitan', # Occitan
 184+ 'om' => 'Oromoo', # Oromo
 185+ 'or' => 'ଓଡ଼ିଆ', # Oriya
 186+ 'os' => 'Иронау', # Ossetic
 187+ 'pa' => 'ਪੰਜਾਬੀ', # Punjabi
 188+ 'pag' => 'Pangasinan', # Pangasinan
 189+ 'pam' => 'Kapampangan', # Pampanga
 190+ 'pap' => 'Papiamentu', # Papiamentu
 191+ 'pdc' => 'Deitsch', # Pennsylvania German
 192+ 'pih' => 'Norfuk / Pitkern', # Norfuk/Pitcairn/Norfolk
 193+ 'pi' => 'पािऴ', # Pali
 194+ 'pl' => 'Polski', # Polish
 195+ 'pms' => 'Piemontèis', # Piedmontese
 196+ 'ps' => 'پښتو', # Pashto
 197+ 'pt' => 'Português', # Portuguese
 198+ 'pt-br' => 'Português do Brasil', # Brazilian Portuguese
 199+ 'qu' => 'Runa Simi', # Quechua
 200+ 'rm' => 'Rumantsch', # Raeto-Romance
 201+ 'rmy' => 'Romani', # Vlax Romany
 202+ 'rn' => 'Kirundi', # Kirundi
 203+ 'ro' => 'Română', # Romanian
 204+ 'roa-rup' => 'Armâneashti', # Aromanian
 205+ 'roa-tara' => 'Tarandíne', # Tarantino
 206+ 'ru' => 'Русский', # Russian
 207+ 'ru-sib' => 'Сибирской', # Siberian/North Russian
 208+ 'rw' => 'Kinyarwanda', # Kinyarwanda, should possibly be Kinyarwandi
 209+ 'sa' => 'संस्कृत', # Sanskrit
 210+ 'sc' => 'Sardu', # Sardinian
 211+ 'scn' => 'Sicilianu', # Sicilian
 212+ 'sco' => 'Scots', # Scots
 213+ 'sd' => 'سنڌي', # Sindhi
 214+ 'se' => 'Sámegiella', # Northern Sami
 215+ 'sg' => 'Sängö', # Sango, possible alternative is Sangho
 216+ 'sh' => 'Srpskohrvatski / Српскохрватски', # Serbocroatian
 217+ 'si' => 'සිංහල', # Sinhalese
 218+ 'simple' => 'Simple English', # Simple English
 219+ 'sk' => 'Slovenčina', # Slovak
 220+ 'sl' => 'Slovenščina', # Slovenian
 221+ 'sm' => 'Gagana Samoa', # Samoan
 222+ 'sn' => 'chiShona', # Shona
 223+ 'so' => 'Soomaaliga', # Somali
 224+ 'sq' => 'Shqip', # Albanian
 225+ 'sr' => 'Српски / Srpski', # Serbian
 226+ 'sr-ec' => 'ћирилица', # Serbian cyrillic ekavian
 227+ 'sr-jc' => 'ијекавица', # Serbian cyrillic iyekvian
 228+ 'sr-el' => 'latinica', # Serbian latin ekavian
 229+ 'sr-jl' => 'ijekavica', # Serbian latin iyekavian
 230+ 'ss' => 'SiSwati', # Swati
 231+ 'st' => 'seSotho', # Southern Sotho
 232+ 'su' => 'Basa Sunda', # Sundanese
 233+ 'sv' => 'Svenska', # Swedish
 234+ 'sw' => 'Kiswahili', # Swahili
 235+ 'ta' => 'தமிழ்', # Tamil
 236+ 'te' => 'తెలుగు', # Telugu
 237+ 'tet' => 'Tetun', # Tetun
 238+ 'tg' => 'Тоҷикӣ', # Tajik
 239+ 'th' => 'ไทย', # Thai
 240+ 'ti' => 'ትግርኛ', # Tigrinya
 241+ 'tk' => 'Türkmen', # Turkmen
 242+ 'tl' => 'Tagalog', # Tagalog (Filipino)
 243+ #'tlh' => 'tlhIngan-Hol', # Klingon - no interlanguage links allowed
 244+ 'tn' => 'Setswana', # Setswana
 245+ 'to' => 'faka-Tonga', # Tonga (Tonga Islands)
 246+ 'tokipona' => 'Toki Pona', # Toki Pona
 247+ 'tp' => 'Toki Pona', # Toki Pona - non-standard language code
 248+ 'tpi' => 'Tok Pisin', # Tok Pisin
 249+ 'tr' => 'Türkçe', # Turkish
 250+ 'ts' => 'Xitsonga', # Tsonga
 251+ 'tt' => 'Tatarça', # Tatar
 252+ 'tum' => 'chiTumbuka', # Tumbuka
 253+ 'tw' => 'Twi', # Twi, (FIXME!)
 254+ 'ty' => 'Reo Mā`ohi', # Tahitian
 255+ 'tyv' => 'Тыва дыл', # Tyvan
 256+ 'udm' => 'Удмурт', # Udmurt
 257+ 'ug' => 'Oyghurque', # Uyghur
 258+ 'uk' => 'Українська', # Ukrainian
 259+ 'ur' => 'اردو', # Urdu
 260+ 'uz' => 'O\'zbek', # Uzbek
 261+ 've' => 'Tshivenda', # Venda
 262+ 'vec' => 'Vèneto', # Venetian
 263+ 'vi' => 'Tiếng Việt', # Vietnamese
 264+ 'vls' => 'West-Vlams', # West Flemish
 265+ 'vo' => 'Volapük', # Volapük
 266+ 'wa' => 'Walon', # Walloon
 267+ 'war' => 'Winaray', # Waray-Waray
 268+ 'wo' => 'Wollof', # Wolof
 269+ 'wuu' => '吴语', # Wu
 270+ 'xal' => 'Хальмг', # Kalmyk
 271+ 'xh' => 'isiXhosa', # Xhosan
 272+ 'yi' => 'ייִדיש', # Yiddish
 273+ 'yo' => 'Yorùbá', # Yoruba
 274+ 'za' => '(Cuengh)', # Zhuang
 275+ 'zea' => 'Zeêuws', # Zealandic
 276+ 'zh' => '中文', # (Zhōng Wén) - Chinese
 277+ 'zh-cfr' => '閩南語', # Min-nan alias (site is at minnan)
 278+ 'zh-classical' => '古文 / 文言文', # Classical Chinese/Literary Chinese
 279+ 'zh-cn' => '中文(简体)', # Simplified
 280+ 'zh-hk' => '中文(繁體)', # Traditional (Hong Kong)
 281+ 'zh-min-nan' => 'Bân-lâm-gú', # Min-nan -- (see bug 8217)
 282+ 'zh-sg' => '中文(简体)', # Simplified (Singapore)
 283+ 'zh-tw' => '中文(繁體)', # Traditional
 284+ 'zh-yue' => '粵語', # Cantonese
 285+ 'zu' => 'isiZulu' # Zulu
 286+);
 287+?>
Index: trunk/extensions/Wikidata/util/voctrain/view.php
@@ -1,6 +1,7 @@
22 <?php
33
44 require_once("settings.php");
 5+require_once("i18n/language.php");
56
67 $header_printed=false;
78 /** This shouldn't be here at all but PEAR:Auth hates me.
@@ -37,45 +38,51 @@
3839 class View {
3940
4041 public $model;
41 -
 42+ public $language;
 43+
 44+ public function __construct($language_code="Default") {
 45+ $this->language=new language($language_code);
 46+ }
 47+
4248 /** print everyones favorite friendly message! */
4349 public function hello() {
44 - print "<h1>HELLO WIKI!</h1>";
 50+ $this->language->i18nprint("<h1><|Hello World|></h1>");
4551 }
4652
4753 /** @deprecated */
4854 public function permissionDenied() {
49 - print "<h1>Permission Denied</h1>";
50 - print "<a href='trainer.php'>Try again?</a>";
 55+ $this->language->i18nprint("<h1><|Permission Denied|></h1>");
 56+ $this->language->i18nprint("<a href='trainer.php'><|try again?|></a>");
5157 }
5258
5359 /** an action was provided, but we've never heard of it
5460 "?action=UnintelligibleGibberish" */
5561 public function actionUnknown($action){
56 - print "<h1>Action unknown</h1>";
57 - print "I don't know what to do with '$action'";
58 - print "<a href='trainer.php'>Try again?</a>";
 62+ $this->language->i18nprint("<h1><|Action unknown|></h1>");
 63+ $this->language->i18nprint("<|I don't know what to do with '%action'.|>", array("action"=>$action));
 64+ $this->language->i18nprint("<a href='trainer.php'><|try_again?|></a>");
5965 }
6066
6167 /** say hello to the new user */
6268 public function userAdded($username) {
63 - print "<h1>User added</h1>";
64 - print "<p>Hello, $username, welcome to the omega language trainer</p>";
65 - print "<p><a href='trainer.php'>continue</a></p>";
 69+
 70+ $this->language->i18nprint("<h1><|User added|></h1>");
 71+ $this->language->i18nprint("<p><|Hello, %username, welcome to the omega language trainer|></p>",array("username"=>$username));
 72+ $this->language->i18nprint("<p><a href='trainer.php'><|continue|></a></p>");
6673 }
6774
6875 /** Big form, allows user to set parameters for their next exercise */
6976 public function exercise_setup($collectionList, $defaultCollection=null) {
70 - print "
71 - <h1>Set up your exercise</h1>
 77+ $this->language->i18nprint("
 78+ <h1><|Set up your exercise|></h1>
7279 <form method='post' action='?'>
73 - <h2> collection </h2>
 80+ <h2><|collection|></h2>
7481 <fieldset class=settings>
7582 <div class='datarow'>
7683 ".$this->collectionSelect($collectionList, $defaultCollection)."
7784 </div>
7885 </fieldset>
79 - <h2>number of questions</h2>
 86+ <h2><|Number of questions|></h2>
8087 <fieldset class='settings'>
8188 <div class='datarow'><input type='radio' value='10' name='exercise_size' /><label>10</label></div><br/>
8289 <div class='datarow'><input type='radio' value='25' name='exercise_size' checked /><label>25</label></div><br/>
@@ -85,17 +92,17 @@
8693 </fieldset>
8794 </p>
8895 </fieldset>
89 - <h2>languages</h2>
 96+ <h2><|Languages|></h2>
9097 <fieldset class='settings'>
9198 <!-- should be a dropdown, perhaps -->
92 - Please specify the languages you want to test in <a href='http://www.sil.org/ISO639-3/codes.asp'>ISO-639-3 format</a>. (eg, eng for English, deu for Deutch (German)). Depending on your test set, some combinations might work better than others.
93 - <div class='datarow'><label>Questions:</label> <input type='text' value='eng' name='questionLanguage'/></div><br/>
94 - <div class='datarow'><label>Answers: </label><input type='text' value='deu' name='answerLanguage'/></li></div><br/>
 99+ <|Please specify the languages you want to test in|> <a href='http://www.sil.org/ISO639-3/codes.asp'><|ISO-639-3 format|></a>. <|(eg, eng for English, deu for Deutch (German)).|> <|Depending on your test set, some combinations might work better than others.|>
 100+ <div class='datarow'><label><|Questions|>:</label> <input type='text' value='eng' name='questionLanguage'/></div><br/>
 101+ <div class='datarow'><label><|Answers|>: </label><input type='text' value='deu' name='answerLanguage'/></li></div><br/>
95102 <hr/>
96103 </p>
97 - <input type='submit' value='start exercise'/>
 104+ <input type='submit' value='<|start exercise|>'/>
98105 </form>
99 - ";
 106+ ");
100107 }
101108
102109 public function collectionSelect($collectionList, $defaultCollection=null) {
@@ -143,47 +150,51 @@
144151 $questions_total=$exercise->countQuestionsTotal();
145152 $answers=implode(", ",$question->getAnswers());
146153
147 - print"<form method='post' action='?action=run_exercise'>
148 - There are $questions_remaining questions remaining, out of a total of $questions_total.
149 - <h1>Question</h1>
 154+ $this->language->i18nprint(
 155+ "<form method='post' action='?action=run_exercise'>
 156+ <|There are %questions_remaining questions remaining, out of a total of %questions_total.|>
 157+ <h1><|Question|></h1>
150158 <hr>
151 - <h2>Definition</h2>
 159+ <h2><|Definition|></h2>
152160 <p class='result'>
153 - <i>Dictionary definition to help you:</i><br/>
 161+ <i><|Dictionary definition to help you|>:</i><br/>
154162 $definitions
155163 </p>
156164 <hr>
157 - <h2>Word</h2>
 165+ <h2><|Word|></h2>
158166 <p class='result'>
159 - <i>The word to translate:</i><br/>
 167+ <i><|The word to translate|>:</i><br/>
160168 $words
161169 </p>
162170 <hr>
163171 <input type='hidden' name='questionDmid' value='$questionDmid'/>
164 - <h2>Answer</h2>
165 - <fieldset class='settings'>";
 172+ <h2><|Answer|></h2>
 173+ <fieldset class='settings'>", array(
 174+ "questions_remaining"=>$questions_remaining,
 175+ "questions_total"=>$questions_total
 176+ ));
166177 if ($peek) {
167 - print"
168 - <i>peek:</i>$answers<br/>";
 178+ $this->language->i18nprint("
 179+ <i><|peek|>:</i>$answers<br/>");
169180 }
170 - print"
171 - <i>Please type your answer here</i><br/>
 181+ $this->language->i18nprint("
 182+ <i><|Please type your answer here|></i><br/>
172183
173184 <input type='text' value='' name='userAnswer' />
174 - <input type='submit' value='submit answer' name='submitAnswer' />
 185+ <input type='submit' value='<|submit answer|>' name='submitAnswer' />
175186 </fieldset>
176187 <fieldset class='settings'>
177 - <input type='submit' value='peek' name='peek' />
178 - <input type='submit' value='skip ->' name='skip' />
179 - <input type='submit' value='I know it/do not ask again' name='hide' />
 188+ <input type='submit' value='<|peek|>' name='peek' />
 189+ <input type='submit' value='<|skip|> ->' name='skip' />
 190+ <input type='submit' value='<|I know it/do not ask again|>' name='hide' />
180191 ".
181192 #<input type='submit' value='never ask again' name='never_ask' />
182193 "
183 - <input type='submit' value='abort exercise' name='abort' />
184 - <input type='submit' value='list answers' name='list_answers' />
 194+ <input type='submit' value='<|abort exercise|>' name='abort' />
 195+ <input type='submit' value='<|list answers|>' name='list_answers' />
185196 </fieldset>
186197 </form>
187 - ";
 198+ ");
188199 }
189200
190201 /** Show the answer to a question */
@@ -199,40 +210,40 @@
200211 } elseif ($correct===false) {
201212 $result="<span style='color:#DD0000'>WRONG</span>";
202213 } elseif ($correct===null) {
203 - $result="PEEK";
 214+ $result="<|peek|>";
204215 } else {
205216 throw new Exception("unexpected outcome from question");
206217 }
207218
208 - print"<form method='post' action='?action=run_exercise'>
 219+ $this->language->i18nprint("<form method='post' action='?action=run_exercise'>
209220 <h2>$result</h2>
210 - Definitions: $definitions
 221+ <|Definitions|>: $definitions
211222 <hr>
212 - Question: $words
 223+ <|Question|>: $words
213224 <hr>
214 - Answer (one of): $answers
 225+ <|Answer|> (<|one of|>): $answers
215226 <hr>
216227 <input type='hidden' name='questionDmid' value='$questionDmid'/>
217228 <input type='submit' value='continue ->' name='continue' />
218229 </form>
219 - ";
 230+ ");
220231 }
221232
222233 /** show a nice final table on completion of the exercise */
223234 public function complete($exercise) {
224235
225 - print "<h1> Exercise complete </h1>";
 236+ $this->language->i18nprint("<h1> <|Exercise complete|> </h1>");
226237 $this->allQuestionsTable($exercise);
227 - print "<a href='?action=create_exercise'>Start a new exercise</a>";
 238+ $this->language->i18nprint("<a href='?action=create_exercise'><|Start a new exercise|></a>");
228239 }
229240
230241 public function listAnswers($exercise) {
231 - print "<h1> list of questions and answers </h1>";
 242+ $this->language->i18nprint("<h1> <|list of questions and answers|> </h1>");
232243 $this->allQuestionsTable($exercise);
233244 print"<fieldset class='settings'>";
234245 print"<form method='post' action='?action=run_exercise'>";
235246 print "<div style='float:right;'>";
236 - print"<input type='submit' value='continue ->' name='continue' />";
 247+ $this->language->i18nprint("<input type='submit' value='<|continue|> ->' name='continue' />");
237248 print"</div>";
238249 print"</fieldset>";
239250 print"</form>";
@@ -244,7 +255,7 @@
245256 */
246257 public function allQuestionsTable($exercise) {
247258 print "<table>";
248 - print "<tr><th>Definition</th><th>Question</th><th>Answer(s)</th></tr>";
 259+ $this->language->i18nprint("<tr><th><|Definition|></th><th><|Question|></th><th><|Answer(s)|></th></tr>");
249260 try {
250261 $exercise->rewind();
251262 foreach ($exercise as $question) {
@@ -265,8 +276,8 @@
266277 * all the untouched questions
267278 */
268279 public function aborted() {
269 - print "<h1> Exercise terminated </h1>\n";
270 - print "<a href='?action=create_exercise'>Start a new exercise</a>";
 280+ $this->language->i18nprint("<h1> <|Exercise terminated|> </h1>\n");
 281+ $this->language->i18nprint("<a href='?action=create_exercise'><|Start a new exercise|></a>");
271282 }
272283
273284 /** fugly function to print HTML header */
@@ -291,7 +302,7 @@
292303 <div id="container">
293304 ';
294305 if ($showlogout) {
295 - print'<a href="?action=logout">logout</a>';
 306+ $this->language->i18nprint('<a href="?action=logout"><|logout|></a>');
296307 }
297308 global $header_printed;
298309 $header_printed=true;
@@ -299,12 +310,12 @@
300311
301312 /** fugly function to print HTML footer */
302313 public function footer() {
303 -print'
304 -<p class="footer">Powered by <a href="http://www.omegawiki.org/">Omegawiki</a></p>
 314+ $this->language->i18nprint('
 315+<p class="footer"><|Powered by|> <a href="http://www.omegawiki.org/"><|Omegawiki|></a></p>
305316 </div>
306317 </body>
307318 </html>
308 -';
 319+');
309320 }
310321
311322

Status & tagging log