]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18766 Towards improved translation
authorstronk7 <stronk7>
Wed, 1 Apr 2009 09:04:21 +0000 (09:04 +0000)
committerstronk7 <stronk7>
Wed, 1 Apr 2009 09:04:21 +0000 (09:04 +0000)
lang/en_utf8/autotranslate.php
lib/autotranslatelib.php

index a8838a92bbc4a88d30f74b1b65705cf3ae8c06c4..beebaf9ea04ece1d648248dcc934113617c34e49 100644 (file)
@@ -4,5 +4,6 @@ $string['autotranslate'] = 'Automatically translate content';
 $string['configautotranslate'] = 'This is a prototype automatic translation system for Moodle, like http://translate.google.com/, but better. At least it will be better in due course, it is still early days and only a few target languages are supported. Improvements to the algorithms are welcome.';
 $string['targetlang_cs_ps'] = 'xIxlxaF0aW5hIChQZXRyIFNrb2Rhayk=';
 $string['targetlang_en_nz_pl'] = 'S2l3aSAoUGVubnkgTGVhY2gp';
+$string['targetlang_en_uk_pl'] = 'QmFzc29vbiAoVGltIEh1bnQp';
 $string['targetlang_null'] = 'Tm8gdHJhbnNsYXRpb24=';
-?>
\ No newline at end of file
+?>
index fa1b6796b1e67a75506bd443ab4df79c21df0930..e2714abebbcf9f69ee47764fcf519f6fa6d74ffe 100644 (file)
@@ -65,7 +65,7 @@ function auto_translate_target_languages() {
     if (!is_null($list)) {
         return $list;
     }
-    $codes = array('null', 'cs_ps', 'en_nz_pl');
+    $codes = array('null', 'cs_ps', 'en_nz_pl', 'en_uk_pl');
     $list = array();
     foreach ($codes as $code) {
         $name = get_string('targetlang_' . $code, 'autotranslate');
@@ -216,3 +216,26 @@ class en_nz_pl_auto_translator extends word_by_word_translator {
         return $this->library[($len - 1) % $this->librarylen];
     }
 }
+
+class en_uk_pl_auto_translator extends word_by_word_translator {
+    private $library = null;
+    private $librarylen;
+    private function ensure_library_loaded() {
+        if (is_null($this->library)) {
+            $this->library = unserialize(base64_decode(
+                'YTo5OntpOjA7czo0OiJjb29sIjtpOjE7czoyOiJ0aCI7aToyO3M6NToiY3Jh' .
+                'enkiO2k6MztzOjc6ImJhc3Nvb24iO2k6NDtzOjEzOiJjb250cmFiYXNzb29u' .
+                'IjtpOjU7czoxMzoiZ28gKHRoZSBnYW1lKSI7aTo2O3M6ODoicXVpei1tYW4i' .
+                'O2k6NztzOjM6Im1hZCI7aTo4O3M6NDoicnRmbSI7fQ=='));
+            $this->librarylen = count($this->library);
+        }
+    }
+    public function translate_word($word) {
+        $len = strlen($word);
+        if ($len == 0) {
+            return '';
+        }
+        $this->ensure_library_loaded();
+        return $this->library[($len - 1) % $this->librarylen];
+    }
+}