Browse Source

First working translation system

pull/5/head
Etenil 15 years ago
parent
commit
9b942b581c
  1. 3
      .gitignore
  2. 97
      i18n/fr_fr.po
  3. 97
      i18n/messages.pot
  4. 15
      i18n/update_po.sh
  5. 6
      i18n/update_trans.sh
  6. 6
      init.php
  7. 30
      lib/Dispatcher.php
  8. 2
      lib/GetConf.php
  9. 2
      lib/PageBuilder.php
  10. 2
      lib/User.php
  11. 2
      lib/Widget.php
  12. 2
      lib/XMPPConnect.php
  13. 4
      lib/i18n.php
  14. 6
      lib/widgets/Account.php
  15. 2
      lib/widgets/Chat.php
  16. 2
      lib/widgets/Friends.php

3
.gitignore

@ -1,4 +1,5 @@
*~
*#*
cache.tmp
log/*
log/*
i18n/files.list

97
i18n/fr_fr.po

@ -0,0 +1,97 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-12-22 16:20+0000\n"
"PO-Revision-Date: 2010-12-22 16:21+0000\n"
"Last-Translator: Etenil <etenil@etenilsrealm.nl>\n"
"Language-Team: French <etenil@etenilsrealm.nl>\n"
"Language: French French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
#: ../lib/Dispatcher.php:42
msgid "MOVIM - Test Client - Welcome to Movim"
msgstr "MOVIM - Client de test - Bienvenue sur Movim"
#: ../lib/Dispatcher.php:43 ../lib/Dispatcher.php:61 ../lib/Dispatcher.php:76
msgid "Home"
msgstr "Accueil"
#: ../lib/Dispatcher.php:44 ../lib/Dispatcher.php:62
msgid "Configuration"
msgstr "Configuration"
#: ../lib/Dispatcher.php:45 ../lib/Dispatcher.php:63
msgid "Logout"
msgstr "Se déconnecter"
#: ../lib/Dispatcher.php:60
msgid "MOVIM - Test Client - Configuration"
msgstr "MOVIM - Client de test - Configuration"
#: ../lib/Dispatcher.php:75
msgid "MOVIM - Test Client - Account Creation"
msgstr "MOVIM - Client de test - Création de compte"
#: ../lib/Dispatcher.php:92
msgid "MOVIM - Test Client - Login to Movim"
msgstr "MOVIM - Client de test - Connexion à Movim"
#: ../lib/Dispatcher.php:95
msgid "Account Creation"
msgstr "Création de compte"
#: ../lib/Dispatcher.php:99
msgid "My address"
msgstr "Mon adresse"
#: ../lib/Dispatcher.php:100 ../lib/widgets/Account.php:35
msgid "Password"
msgstr "Mot de passe"
#: ../lib/Dispatcher.php:101
msgid "Come in!"
msgstr "Entrez!"
#: ../lib/GetConf.php:42
#, php-format
msgid "Error: Cannot load file `%s'"
msgstr "Erreur: Fichier << %s >> introuvable"
#: ../lib/PageBuilder.php:250
#, php-format
msgid "Error: Requested widget '%s' doesn't exist."
msgstr "Erreur: Le widget << %s >> n'existe pas."
#: ../lib/User.php:64
#, fuzzy
msgid "Wrong password"
msgstr "Mot de passe incorrect"
#: ../lib/Widget.php:69
msgid "This is a sample widget."
msgstr "Ceci est un widget de test"
#: ../lib/XMPPConnect.php:154
#, php-format
msgid "Error: jid `%s' is incorrect"
msgstr "L'addresse Jabber << %s >> est incorrecte"
#: ../lib/widgets/Account.php:32 ../lib/widgets/Account.php:34
msgid "Jabber Account"
msgstr "Compte Jabber"
#: ../lib/widgets/Chat.php:40
msgid "Send"
msgstr "Envoyer"
#: ../lib/widgets/Friends.php:65
msgid "Contacts"
msgstr "Contacts"

97
i18n/messages.pot

@ -0,0 +1,97 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-12-22 16:20+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../lib/Dispatcher.php:42
msgid "MOVIM - Test Client - Welcome to Movim"
msgstr ""
#: ../lib/Dispatcher.php:43 ../lib/Dispatcher.php:61 ../lib/Dispatcher.php:76
msgid "Home"
msgstr ""
#: ../lib/Dispatcher.php:44 ../lib/Dispatcher.php:62
msgid "Configuration"
msgstr ""
#: ../lib/Dispatcher.php:45 ../lib/Dispatcher.php:63
msgid "Logout"
msgstr ""
#: ../lib/Dispatcher.php:60
msgid "MOVIM - Test Client - Configuration"
msgstr ""
#: ../lib/Dispatcher.php:75
msgid "MOVIM - Test Client - Account Creation"
msgstr ""
#: ../lib/Dispatcher.php:92
msgid "MOVIM - Test Client - Login to Movim"
msgstr ""
#: ../lib/Dispatcher.php:95
msgid "Account Creation"
msgstr ""
#: ../lib/Dispatcher.php:99
msgid "My address"
msgstr ""
#: ../lib/Dispatcher.php:100 ../lib/widgets/Account.php:35
msgid "Password"
msgstr ""
#: ../lib/Dispatcher.php:101
msgid "Come in!"
msgstr ""
#: ../lib/GetConf.php:42
#, php-format
msgid "Error: Cannot load file `%s'"
msgstr ""
#: ../lib/PageBuilder.php:250
#, php-format
msgid "Error: Requested widget '%s' doesn't exist."
msgstr ""
#: ../lib/User.php:64
msgid "Wrong password"
msgstr ""
#: ../lib/Widget.php:69
msgid "This is a sample widget."
msgstr ""
#: ../lib/XMPPConnect.php:154
#, php-format
msgid "Error: jid `%s' is incorrect"
msgstr ""
#: ../lib/widgets/Account.php:32 ../lib/widgets/Account.php:34
msgid "Jabber Account"
msgstr ""
#: ../lib/widgets/Chat.php:40
msgid "Send"
msgstr ""
#: ../lib/widgets/Friends.php:65
msgid "Contacts"
msgstr ""

15
i18n/update_po.sh

@ -0,0 +1,15 @@
#!/bin/bash
# Should we only update a language?
if [ $# -eq 1 ]
then
echo "Updating language ${1}"
msgmerge -o "${1}.po" "${1}.po" messages.pot
else
echo "Updating all tranlations"
for lang in *.po
do
echo ${lang%.po}
msgmerge -o "$lang" "$lang" messages.pot
done
fi

6
i18n/update_trans.sh

@ -0,0 +1,6 @@
#!/bin/sh
ls ../lib/*.php > files.list
ls ../lib/widgets/*.php >> files.list
xgettext -kt -o messages.pot -L PHP -f files.list

6
init.php

@ -9,7 +9,9 @@ define('LIB_PATH',BASE_PATH.'lib/');
define('PROPERTIES_PATH',BASE_PATH.'page/properties/');
define('THEMES_PATH', BASE_PATH . 'themes/');
require_once('BASE_PATH' . 'i18n.php');
require_once(LIB_PATH . 'i18n.php');
load_language('fr_fr');
{
$index_pos = strpos($_SERVER['PHP_SELF'], 'index.php');
@ -65,7 +67,7 @@ function __autoload($className) {
if(file_exists($file)) {
require_once($file);
} else {
throw new MovimException(_("Erreur Autoload : le fichier {$file} n'existe pas"));
throw new MovimException(t("Erreur Autoload : le fichier {$file} n'existe pas"));
}
}

30
lib/Dispatcher.php

@ -39,10 +39,10 @@ class Dispatcher extends Controller
if(!$user->isLogged()) {
$this->login();
} else {
$this->page->setTitle(_('MOVIM - Test Client - Welcome to Movim'));
$this->page->menuAddLink($this->page->theme_img('img/home_icon.png', 'home_icon')._('Home'), '?q=mainPage');
$this->page->menuAddLink(_('Configuration'), '?q=config');
$this->page->menuAddLink(_('Logout'), '?q=disconnect');
$this->page->setTitle(t('MOVIM - Test Client - Welcome to Movim'));
$this->page->menuAddLink($this->page->theme_img('img/home_icon.png', 'home_icon').t('Home'), '?q=mainPage');
$this->page->menuAddLink(t('Configuration'), '?q=config');
$this->page->menuAddLink(t('Logout'), '?q=disconnect');
$content = new PageBuilder($user);
$this->page->setContent($content->build('main.tpl'));
@ -57,10 +57,10 @@ class Dispatcher extends Controller
if(!$user->isLogged()) {
$this->login();
} else {
$this->page->setTitle(_('MOVIM - Test Client - Configuration'));
$this->page->menuAddLink($this->page->theme_img('img/home_icon.png', 'home_icon')._('Home'), '?q=mainPage');
$this->page->menuAddLink(_('Configuration'), '?q=config');
$this->page->menuAddLink(_('Logout'), '?q=disconnect');
$this->page->setTitle(t('MOVIM - Test Client - Configuration'));
$this->page->menuAddLink($this->page->theme_img('img/home_icon.png', 'home_icon').t('Home'), '?q=mainPage');
$this->page->menuAddLink(t('Configuration'), '?q=config');
$this->page->menuAddLink(t('Logout'), '?q=disconnect');
$content = new PageBuilder($user);
@ -72,8 +72,8 @@ class Dispatcher extends Controller
function account()
{
if(GetConf::getConfElement("accountCreation") == 1) {
$this->page->setTitle(_('MOVIM - Test Client - Account Creation'));
$this->page->menuAddLink($this->page->theme_img('img/home_icon.png', 'home_icon')._('Home'), '?q=mainPage');
$this->page->setTitle(t('MOVIM - Test Client - Account Creation'));
$this->page->menuAddLink($this->page->theme_img('img/home_icon.png', 'home_icon').t('Home'), '?q=mainPage');
$content = new PageBuilder($user);
$this->page->setContent($content->build('account.tpl'));
@ -89,16 +89,16 @@ class Dispatcher extends Controller
*/
function login()
{
$this->page->setTitle(_('MOVIM - Test Client - Login to Movim'));
$this->page->setTitle(t('MOVIM - Test Client - Login to Movim'));
$this->page->menuAddLink('Movim | Human Network', 'http://www.movim.eu/');
if(GetConf::getConfElement("accountCreation") == 1)
$this->page->menuAddLink(_('Account Creation'), '?q=account');
$this->page->menuAddLink(t('Account Creation'), '?q=account');
$this->page->setContent(
'<div id="connect_form">'.
'<form id="authForm" action="index.php" method="post">'.
'<input type="text" name="login" id="login" value="'._("My address").'" class="write"/>'.
'<input type="password" name="pass" id="pass" value="'._("Password").'" class="write"/><br />'.
'<input class="submit" style="float: none;"type="submit" name="submit" value="'._("Come in!").'"/>'.
'<input type="text" name="login" id="login" value="'.t("My address").'" class="write"/>'.
'<input type="password" name="pass" id="pass" value="'.t("Password").'" class="write"/><br />'.
'<input class="submit" style="float: none;"type="submit" name="submit" value="'.t("Come in!").'"/>'.
'</form>'.
'</div>');
echo $this->page->build('page.tpl');

2
lib/GetConf.php

@ -39,7 +39,7 @@ class GetConf
static function readConfFile($file_path) {
if(!file_exists($file_path)) {
throw new MovimException(sprintf(_("Error: Cannot load file `%s'"), $file_path));
throw new MovimException(sprintf(t("Error: Cannot load file `%s'"), $file_path));
}
$file = simplexml_load_file($file_path);

2
lib/PageBuilder.php

@ -247,7 +247,7 @@ class PageBuilder
self::$scripts = array_merge(self::$scripts, $widget->loadjs());
} else {
throw new MovimException(
sprintf(_("Error: Requested widget '%s' doesn't exist."), $name));
sprintf(t("Error: Requested widget '%s' doesn't exist."), $name));
}
}

2
lib/User.php

@ -61,7 +61,7 @@ class User {
$this->username = $login;
$this->password = $pass;
} else {
throw new MovimException(_("Mauvais mot de passe"));
throw new MovimException(t("Wrong password"));
}
}
catch(MovimException $e){

2
lib/Widget.php

@ -66,7 +66,7 @@ class Widget
*/
function build()
{
echo _("This is a sample widget.");
echo t("This is a sample widget.");
}
/**

2
lib/XMPPConnect.php

@ -151,7 +151,7 @@ class XMPPConnect
public function login($jid, $pass)
{
if(!$this->checkJid($jid)) {
throw new MovimException(sprintf(_("Error: jid `%s' is incorrect"), $jid));
throw new MovimException(sprintf(t("Error: jid `%s' is incorrect"), $jid));
} else {
$id = explode('@',$jid);
$user = $id[0];

4
lib/i18n.php

@ -38,8 +38,8 @@ function t($string)
global $language;
global $translations;
if(isset($custom_strings[$string])) {
return $custom_strings[$string];
if(isset($translations[$string])) {
return $translations[$string];
}
return $string;

6
lib/widgets/Account.php

@ -29,10 +29,10 @@ class Account extends Widget
{
$form = new Form();
$form->startForm(basename($_SERVER['PHP_SELF']));
$form->startFieldset(_('Jabber Account'));
$form->startFieldset(t('Jabber Account'));
$form->newline = true;
$form->textInput('account',_('Jabber Account'),false,'block required');
$form->textInput('password',_('Password'),false,'block required');
$form->textInput('account',t('Jabber Account'),false,'block required');
$form->textInput('password',t('Password'),false,'block required');
$form->newline = true;
$form->closeFieldset();
$form->insertBR();

2
lib/widgets/Chat.php

@ -37,7 +37,7 @@ class Chat extends Widget
<p>Pouet: Gna gna gna!</p>
</div>
<input type="text" id="chatInput" />
<input type="button" id="chatSend" value="<?php echo _('Send');?>"/>
<input type="button" id="chatSend" value="<?php echo t('Send');?>"/>
</div>
<?php
}

2
lib/widgets/Friends.php

@ -62,7 +62,7 @@ class Friends extends Widget
$xmpp->getRosterList();
$list = $xmpp->getPayload();
echo "<br /><br /><h3>"._('Contacts')."</h3>".
echo "<br /><br /><h3>".t('Contacts')."</h3>".
"<div id='tinylist'><ul>\n";
for($i=0;$i< sizeof($list["queryItemName"]); $i++) {
echo "<li><a href='".

Loading…
Cancel
Save