translate properties UI, output ru in utf8

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@200 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2008-11-27 00:55:54 +00:00
parent add773dd9f
commit 40992e395a
7 changed files with 258 additions and 51 deletions

View File

@ -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

View File

@ -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]))

View File

@ -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

View File

@ -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=Ôîòîãðàôèÿ

View File

@ -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] : "<b><unknown></b>";
$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] : "<font color=\"#c13030\"><b>absent</b></font>") );
}
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');
?>

View File

@ -40,41 +40,76 @@
</td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getlocal2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='<?php echo $webimroot ?>/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="<?php echo $webimroot ?>/operator/index.php" title="<?php echo getlocal("menu.main") ?>"><?php echo getlocal("menu.main") ?></a></td></tr></table></td></tr></table>
<?php echo getlocal("page.translate.descr") ?>
<br />
<br />
<?php if( $page['pagination'] && $page['pagination.items'] ) { ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td class='table' bgcolor='#276db8' height='30'><span class='header'>Key</span></td><td width='3'></td>
<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo topage($page['title1']) ?></span></td><td width='3'></td>
<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo topage($page['title2']) ?></span></td>
</tr>
<?php foreach( $page['pagination.items'] as $localstr ) { ?>
<tr>
<td height='20' class='table'>
<a href="<?php echo $webimroot ?>/operator/translate.php?target=<?php echo $page['lang2'] ?>&stringid=<?php echo $localstr['id'] ?>" target="_blank" onclick="this.newWindow = window.open('<?php echo $webimroot ?>/operator/translate.php?target=<?php echo $page['lang2'] ?>&stringid=<?php echo $localstr['id'] ?>', '', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,width=640,height=480,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;"><?php echo topage($localstr['id']) ?></a>
</td><td background='<?php echo $webimroot ?>/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='<?php echo $webimroot ?>/images/free.gif'></td>
<td height='20' class='table'>
<?php echo topage($localstr['l1']) ?>
</td><td background='<?php echo $webimroot ?>/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='<?php echo $webimroot ?>/images/free.gif'></td>
<td height='20' class='table'>
<?php echo topage($localstr['l2']) ?>
</td>
</tr>
<tr><td height='2' colspan='9'></td></tr><tr><td bgcolor='#e1e1e1' colspan='9'><img width='1' height='1' border='0' alt='' src='<?php echo $webimroot ?>/images/free.gif'></td></tr><tr><td height='2' colspan='9'></td></tr>
<?php } ?>
</table>
<br />
<?php echo generate_pagination($page['pagination']) ?>
<?php if( $page['saved'] ) { ?>
<?php echo getlocal("page.translate.done") ?>
<script><!--
setTimeout( (function() { window.close(); }), 500 );
//--></script>
<?php } ?>
<?php if( $page['pagination'] && !$page['pagination.items'] ) { ?>
<br/><br/>
<table cellspacing='0' cellpadding='0' border='0'><tr><td background='<?php echo $webimroot ?>/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
<span class="table">
<?php echo getlocal("tag.pagination.no_items") ?>
</span>
</table></td><td></td></tr><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
<?php if( !$page['saved'] ) { ?>
<?php echo getlocal("page.translate.one") ?>
<br/>
<br/>
<?php if( isset($errors) && count($errors) > 0 ) { ?>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="top"><img src='<?php echo $webimroot ?>/images/icon_err.gif' width="40" height="40" border="0" alt="" /></td>
<td width="10"></td>
<td class="text">
<?php if( isset($errors) && count($errors) > 0 ) {
print getlocal("errors.header");
foreach( $errors as $e ) {
print getlocal("errors.prefix");
print $e;
print getlocal("errors.suffix");
}
print getlocal("errors.footer");
} ?>
</td>
</tr>
</table>
<?php } ?>
<form name="translateForm" method="post" action="<?php echo $webimroot ?>/operator/translate.php">
<table cellspacing='0' cellpadding='0' border='0'><tr><td background='<?php echo $webimroot ?>/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
<tr>
<td colspan="3" class="formauth"><?php echo $page['title1'] ?></td>
</tr>
<tr><td colspan="3" height="2"></td></tr>
<tr>
<td colspan="3">
<textarea name="original" disabled="disabled" tabindex="0" cols="80" rows="5" style="border:1px solid #878787; overflow:auto"><?php echo $page['formoriginal'] ?></textarea>
</td>
</tr>
<tr><td colspan="3" height="5"></td></tr>
<tr>
<td colspan="3" class="formauth"><?php echo $page['title2'] ?></td>
</tr>
<tr><td colspan="3" height="2"></td></tr>
<tr>
<td colspan="3">
<textarea name="translation" tabindex="0" cols="80" rows="5" style="border:1px solid #878787; overflow:auto"><?php echo $page['formtranslation'] ?></textarea>
</td>
</tr>
<tr><td colspan="3" height="5"></td></tr>
<tr><td colspan='3' height='20'></td></tr><tr><td colspan='3' background='<?php echo $webimroot ?>/images/formline.gif'><img src='<?php echo $webimroot ?>/images/formline.gif' width='1' height='2' border='0' alt=''></td></tr><tr><td colspan='3' height='10'></td></tr>
<tr>
<td class="formauth">
<input type="hidden" name="key" value="<?php echo $page['key'] ?>"/>
<input type="hidden" name="target" value="<?php echo $page['target'] ?>"/>
<input type="image" name="" src='<?php echo $webimroot.getlocal("image.button.save") ?>' border="0" alt='<?php echo getlocal("button.save") ?>'/></td>
<td></td>
<td></td>
</tr>
</table></td><td></td></tr><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
</form>
<?php } ?>
</td>

View File

@ -0,0 +1,99 @@
<?php
/*
* This file is part of Web Instant Messenger project.
*
* Copyright (c) 2005-2008 Web Messenger Community
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Gryaznov - initial API and implementation
*/
?>
<html>
<head>
<link rel="stylesheet" type="text/css" media="all" href="<?php echo $webimroot ?>/styles.css" />
<link rel="shortcut icon" href="<?php echo $webimroot ?>/images/favicon.ico" type="image/x-icon"/>
<title>
<?php echo getlocal("app.title") ?> - <?php echo getlocal("page.translate.title") ?>
</title>
<meta http-equiv="keywords" content="<?php echo getlocal("page.main_layout.meta_keyword") ?>">
<meta http-equiv="description" content="<?php echo getlocal("page.main_layout.meta_description") ?>">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td valign="top" class="text">
<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top">
<h1><?php echo getlocal("page.translate.title") ?></h1>
</td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getlocal2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='<?php echo $webimroot ?>/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="<?php echo $webimroot ?>/operator/index.php" title="<?php echo getlocal("menu.main") ?>"><?php echo getlocal("menu.main") ?></a></td></tr></table></td></tr></table>
<?php echo getlocal("page.translate.descr") ?>
<br />
<br />
<form name="translateForm" method="get" action="<?php echo $webimroot ?>/operator/translate.php">
<table cellspacing='0' cellpadding='0' border='0'><tr><td background='<?php echo $webimroot ?>/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
<tr>
<td class="formauth" colspan="3">
<select name="source" onchange="this.form.submit();"><?php foreach($page['availableLocales'] as $k) { echo "<option value=\"".$k["id"]."\"".($k["id"] == form_value("source") ? " selected=\"selected\"" : "").">".$k["name"]."</option>"; } ?></select>
=>
<select name="target" onchange="this.form.submit();"><?php foreach($page['availableLocales'] as $k) { echo "<option value=\"".$k["id"]."\"".($k["id"] == form_value("target") ? " selected=\"selected\"" : "").">".$k["name"]."</option>"; } ?></select>
</td>
</tr>
</table></td><td></td></tr><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
</form>
<br/>
<?php if( $page['pagination'] && $page['pagination.items'] ) { ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td class='table' bgcolor='#276db8' height='30'><span class='header'>Key</span></td><td width='3'></td>
<td class='table' bgcolor='#276db8' height='30'width="40%"><span class='header'><?php echo topage($page['title1']) ?></span></td><td width='3'></td>
<td class='table' bgcolor='#276db8' height='30'width="40%"><span class='header'><?php echo topage($page['title2']) ?></span></td>
</tr>
<?php foreach( $page['pagination.items'] as $localstr ) { ?>
<tr>
<td height='20' class='table'>
<a href="<?php echo $webimroot ?>/operator/translate.php?source=<?php echo $page['lang1'] ?>&amp;target=<?php echo $page['lang2'] ?>&amp;key=<?php echo $localstr['id'] ?>" target="_blank" onclick="this.newWindow = window.open('<?php echo $webimroot ?>/operator/translate.php?source=<?php echo $page['lang1'] ?>&amp;target=<?php echo $page['lang2'] ?>&amp;key=<?php echo $localstr['id'] ?>', '', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,width=640,height=430,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;"><?php echo topage($localstr['id']) ?></a>
</td><td background='<?php echo $webimroot ?>/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='<?php echo $webimroot ?>/images/free.gif'></td>
<td height='20' class='table'>
<?php echo topage($localstr['l1']) ?>
</td><td background='<?php echo $webimroot ?>/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='<?php echo $webimroot ?>/images/free.gif'></td>
<td height='20' class='table'>
<?php echo topage($localstr['l2']) ?>
</td>
</tr>
<tr><td height='2' colspan='9'></td></tr><tr><td bgcolor='#e1e1e1' colspan='9'><img width='1' height='1' border='0' alt='' src='<?php echo $webimroot ?>/images/free.gif'></td></tr><tr><td height='2' colspan='9'></td></tr>
<?php } ?>
</table>
<br />
<?php echo generate_pagination($page['pagination']) ?>
<?php } ?>
<?php if( $page['pagination'] && !$page['pagination.items'] ) { ?>
<br/><br/>
<table cellspacing='0' cellpadding='0' border='0'><tr><td background='<?php echo $webimroot ?>/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
<span class="table">
<?php echo getlocal("tag.pagination.no_items") ?>
</span>
</table></td><td></td></tr><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
<?php } ?>
</td>
</tr>
</table>
</body>
</html>