MDL-18766 Towards improved translation

This commit is contained in:
stronk7
2009-04-01 09:04:21 +00:00
parent 497bad9012
commit c66158102e
2 changed files with 26 additions and 2 deletions
+2 -1
View 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=';
?>
?>
+24 -1
View 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];
}
}