diff --git a/src/messenger/.settings/org.eclipse.core.resources.prefs b/src/messenger/.settings/org.eclipse.core.resources.prefs index 40b2ec46..b0cba131 100644 --- a/src/messenger/.settings/org.eclipse.core.resources.prefs +++ b/src/messenger/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,5 @@ -#Tue Sep 30 01:27:05 CEST 2008 +#Thu Nov 27 00:52:16 CET 2008 eclipse.preferences.version=1 encoding//webim/INSTALL_RUS.txt=cp1251 encoding//webim/locales/ru=cp1251 +encoding//webim/locales/sp/properties=ISO-8859-1 diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php index 6e268bcc..dfac34d3 100644 --- a/src/messenger/webim/libs/common.php +++ b/src/messenger/webim/libs/common.php @@ -150,6 +150,34 @@ function load_messages($locale) { $messages[$locale] = $hash; } +function save_message($locale,$key,$value) { + global $webim_encoding; + $result = ""; + $added = false; + $current_encoding = $webim_encoding; + $fp = fopen(dirname(__FILE__)."/../locales/$locale/properties", "r"); + while (!feof($fp)) { + $line = fgets($fp, 4096); + $keyval = split("=", $line, 2 ); + if( isset($keyval[1]) ) { + if($keyval[0] == 'encoding') { + $current_encoding = trim($keyval[1]); + } else if(!$added && $keyval[0] == $key) { + $line = "$key=".myiconv($webim_encoding, $current_encoding, str_replace("\n", "\\n",trim($value)))."\n"; + $added = true; + } + } + $result .= $line; + } + fclose($fp); + if(!$added) { + $result .= "$key=".myiconv($webim_encoding, $current_encoding, str_replace("\n", "\\n",trim($value)))."\n"; + } + $fp = fopen(dirname(__FILE__)."/../locales/$locale/properties", "w"); + fwrite($fp, $result); + fclose($fp); +} + function getoutputenc() { global $current_locale, $output_encoding, $webim_encoding, $messages; if(!isset($messages[$current_locale])) diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index 9932b3eb..9d066a57 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -191,6 +191,7 @@ form.field.agent_commonname.description=This name will be seen by your visitors. form.field.email=Your email form.field.message=Message form.field.name=Your name +form.field.translation=Translation install.1.connected=You are connected to MySQL server version {0} install.2.create=Create database "{0}" install.2.db_exists=Database "{0}" is created. @@ -251,6 +252,8 @@ page.preview.style_default=-from general settings- page.preview.title=Site style page.preview.userchat=Chat window (user-mode) page.translate.descr=If you don't like the translation, please send us an update. +page.translate.done=Your translation is saved. +page.translate.one=Enter you translation. page.translate.title=Translate Open WebIM page_agent.create_new=Here you can create new operator page_agent.tab.avatar=Photo diff --git a/src/messenger/webim/locales/ru/properties b/src/messenger/webim/locales/ru/properties index c6e14786..d6f3f44c 100644 --- a/src/messenger/webim/locales/ru/properties +++ b/src/messenger/webim/locales/ru/properties @@ -1,6 +1,6 @@ encoding=cp1251 -output_charset=Windows-1251 -output_encoding=cp1251 +output_charset=utf-8 +output_encoding=utf-8 site.url=http://webim.sourceforge.net site.title=webim.sf.net company.title=Web Messenger Community @@ -191,6 +191,7 @@ form.field.agent_commonname.description= form.field.email=Ваш email form.field.message=Сообщение form.field.name=Ваше имя +form.field.translation=Текст перевода install.1.connected=Вы подсоединены к серверу MySQL версии {0}. install.2.create=Создать базу данных "{0}" install.2.db_exists=Создана база данных "{0}". @@ -251,6 +252,8 @@ page.preview.style_default=- page.preview.title=Стиль мессенджера page.preview.userchat=Chat window (user-mode) page.translate.descr=Если вам не нравится перевод, пришлите нам ваш вариант. +page.translate.done=Ваш перевод сохранен. +page.translate.one=Введите ваш вариант перевода. page.translate.title=Переведите Open WebIM page_agent.create_new=Создание нового оператора page_agent.tab.avatar=Фотография diff --git a/src/messenger/webim/operator/translate.php b/src/messenger/webim/operator/translate.php index fb07237b..a47d3446 100644 --- a/src/messenger/webim/operator/translate.php +++ b/src/messenger/webim/operator/translate.php @@ -16,37 +16,75 @@ require_once('../libs/common.php'); require_once('../libs/operator.php'); require_once('../libs/pagination.php'); -$source = "en"; -$target = verifyparam("target", "/^[\w-]{2,5}$/", "en"); - $operator = check_login(); -$page = array( - 'operator' => topage(get_operator_name($operator)), - 'lang1' => $source, - 'lang2' => $target -); +$source = verifyparam("source", "/^[\w-]{2,5}$/", $default_locale); +$target = verifyparam("target", "/^[\w-]{2,5}$/", $home_locale); +$stringid = verifyparam("key", "/^[_\.\w]+$/", ""); if(!isset($messages[$source])) { load_messages($source); } +$lang1 = $messages[$source]; if(!isset($messages[$target])) { load_messages($target); } -$lang1 = $messages[$source]; $lang2 = $messages[$target]; -$page["title1"] = isset($lang1["localeid"]) ? $lang1["localeid"] : $source; -$page["title2"] = isset($lang2["localeid"]) ? $lang2["localeid"] : $target; +$errors = array(); +$page = array( + 'operator' => topage(get_operator_name($operator)), + 'lang1' => $source, + 'lang2' => $target, + 'title1' => isset($lang1["localeid"]) ? $lang1["localeid"] : $source, + 'title2' => isset($lang2["localeid"]) ? $lang2["localeid"] : $target +); + +if($stringid) { + $translation = isset($lang2[$stringid]) ? $lang2[$stringid] : ""; + if(isset($_POST['translation'])) { + + $translation = getparam('translation'); + + if(!$translation) { + $errors[] = no_field("form.field.translation"); + } + + if(count($errors) == 0) { + save_message($target, $stringid, $translation); + + $page['saved'] = true; + start_html_output(); + require('../view/translate.php'); + exit; + } + } + + $page['saved'] = false; + $page['key'] = $stringid; + $page['target'] = $target; + $page['formoriginal'] = isset($lang1[$stringid]) ? $lang1[$stringid] : ""; + $page['formtranslation'] = $translation; + start_html_output(); + require('../view/translate.php'); + exit; +} + +$localesList = array(); +foreach($available_locales as $loc) { + $localesList[] = array("id" => $loc, "name" => getlocal_("localeid", $loc)); +} $result = array(); $allkeys = array_keys($lang1); foreach($allkeys as $key) { $result[] = array('id' => $key, 'l1' => $lang1[$key], 'l2' => (isset($lang2[$key]) ? $lang2[$key] : "absent") ); } +setup_pagination($result,100); -setup_pagination($result); - +$page['formtarget'] = $target; +$page['formsource'] = $source; +$page['availableLocales'] = $localesList; start_html_output(); -require('../view/translate.php'); +require('../view/translatelist.php'); ?> \ No newline at end of file diff --git a/src/messenger/webim/view/translate.php b/src/messenger/webim/view/translate.php index fb52dde8..0af7605a 100644 --- a/src/messenger/webim/view/translate.php +++ b/src/messenger/webim/view/translate.php @@ -40,41 +40,76 @@
|">
- -
-
- - - - - - - - - - - - - - - -
Key
- - - - - -
-
- + + + + - -

-
- - - -
+ + + +
+
+ + 0 ) { ?> + + + + + + +
+ 0 ) { + print getlocal("errors.header"); + foreach( $errors as $e ) { + print getlocal("errors.prefix"); + print $e; + print getlocal("errors.suffix"); + } + print getlocal("errors.footer"); + } ?> + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + +
+
diff --git a/src/messenger/webim/view/translatelist.php b/src/messenger/webim/view/translatelist.php new file mode 100644 index 00000000..b2ec7a27 --- /dev/null +++ b/src/messenger/webim/view/translatelist.php @@ -0,0 +1,99 @@ + + + + + + + + + + + + <?php echo getlocal("app.title") ?> - <?php echo getlocal("page.translate.title") ?> + + +"> +"> + + + + + + + + +
+ +
+

+
|">
+ + + +
+
+ +
+
+ + + +
+ + => + +
+
+
+ + + + + + + + + + + + + + + +
Key
+ + + + + +
+
+ + + +

+
+ + + +
+ + +
+ + + +