From f391082595732fedb7c5627c7e924ac68446de1e Mon Sep 17 00:00:00 2001 From: Pascal Chevrel Date: Mon, 30 Apr 2012 13:41:57 +0200 Subject: Update l10n support: - improved regex logic in the extraction parser (fixes a couple of bugs in edge cases) - *.tpl.php files were not parsed because of the double dot, now fixed - strings requiring translation are now indicated in the source file to make them stand out - support for the {ok} tag, adding this tag allows the localizer to indicate that a string remains in English (or that it is spelt the same in his language) - add an english reference file, in case we want to send it to volunteers --- app/classes/Simplel10n.class.php | 12 ++ app/l10n/en.lang | 270 +++++++++++++++++++++++++++++++++++++++ app/l10n/extract.php | 27 ++-- app/l10n/fr.lang | 243 ++++++++++++++++++++--------------- 4 files changed, 440 insertions(+), 112 deletions(-) mode change 100644 => 100755 app/classes/Simplel10n.class.php create mode 100644 app/l10n/en.lang mode change 100644 => 100755 app/l10n/extract.php (limited to 'app') diff --git a/app/classes/Simplel10n.class.php b/app/classes/Simplel10n.class.php old mode 100644 new mode 100755 index 36ac958..7af8564 --- a/app/classes/Simplel10n.class.php +++ b/app/classes/Simplel10n.class.php @@ -18,6 +18,18 @@ class Simplel10n { } static function getString($str, $comment='') { + if(array_key_exists($str, $GLOBALS['locale'])) { + return trim(str_replace('{ok}', '', $GLOBALS['locale'][$str])); + } else { + return $str; + } + } + + /* + * This is the same as getString except that we don't remove the {ok} string + * This is needed only for the extraction script + */ + static function extractString($str, $comment='') { if(array_key_exists($str, $GLOBALS['locale'])) { return $GLOBALS['locale'][$str]; } else { diff --git a/app/l10n/en.lang b/app/l10n/en.lang new file mode 100644 index 0000000..64d5a82 --- /dev/null +++ b/app/l10n/en.lang @@ -0,0 +1,270 @@ +# Translation note: ** String needs translation ** +;Are you sure you want to purge the cache? +Are you sure you want to purge the cache? + + +# Translation note: ** String needs translation ** +;Clear cache +Clear cache + + +# Translation note: ** String needs translation ** +;Clear cache: +Clear cache: + + +# Translation note: ** String needs translation ** +;Clear +Clear + + +# Translation note: ** String needs translation ** +;Clearing the cache will make moonmoon reload all feeds. +Clearing the cache will make moonmoon reload all feeds. + + +# Translation note: ** String needs translation ** +;Change administrator password +Change administrator password + + +# Translation note: ** String needs translation ** +;New password: +New password: + + +# Translation note: ** String needs translation ** +;Change password +Change password + + +# Translation note: ** String needs translation ** +;Add Feed +Add Feed + + +# Translation note: ** String needs translation ** +;Link: +Link: + + +# Translation note: ** String needs translation ** +;Accepted formats are RSS and ATOM. If the link is not a feed, moonmoon will try to autodiscover the feed. +Accepted formats are RSS and ATOM. If the link is not a feed, moonmoon will try to autodiscover the feed. + + +# Translation note: ** String needs translation ** +;Manage existing feeds +Manage existing feeds + + +# Translation note: ** String needs translation ** +;Number of feeds: %s +Number of feeds: %s + + +# Translation note: ** String needs translation ** +;Save changes +Save changes + + +# Translation note: ** String needs translation ** +;Delete selected Feeds +Delete selected Feeds + + +# Translation note: ** String needs translation ** +;Select : +Select : + + +# Translation note: ** String needs translation ** +;All +All + + +# Translation note: ** String needs translation ** +;None +None + + +# Translation note: ** String needs translation ** +;Selection +Selection + + +# Translation note: ** String needs translation ** +;Name +Name + + +# Translation note: ** String needs translation ** +;Last entry +Last entry + + +# Translation note: ** String needs translation ** +;Website link +Website link + + +# Translation note: ** String needs translation ** +;Feed link +Feed link + + +# Translation note: ** String needs translation ** +;Not in cache +Not in cache + + +# Translation note: ** String needs translation ** +;Password: +Password: + + +# Translation note: ** String needs translation ** +;OK +OK + + +# Translation note: ** String needs translation ** +;moonmoon administration +moonmoon administration + + +# Translation note: ** String needs translation ** +;Back to main page +Back to main page + + +# Translation note: ** String needs translation ** +;Logout +Logout + + +# Translation note: ** String needs translation ** +;Feeds +Feeds + + +# Translation note: ** String needs translation ** +;Administration +Administration + + +# Translation note: ** String needs translation ** +;Powered by moonmoon +Powered by moonmoon + + +# Translation note: ** String needs translation ** +;No article +No article + + +# Translation note: ** String needs translation ** +;No news, good news. +No news, good news. + + +# Translation note: ** String needs translation ** +;Today +Today + + +# Translation note: ** String needs translation ** +;Go to original place +Go to original place + + +# Translation note: ** String needs translation ** +;This week +This week + + +# Translation note: ** String needs translation ** +;This month +This month + + +# Translation note: ** String needs translation ** +;Older items +Older items + + +# Translation note: ** String needs translation ** +;People +People + + +# Translation note: ** String needs translation ** +;Feed +Feed + + +# Translation note: ** String needs translation ** +;Website +Website + + +# Translation note: ** String needs translation ** +;All feeds in OPML format +All feeds in OPML format + + +# Translation note: ** String needs translation ** +;Syndicate +Syndicate + + +# Translation note: ** String needs translation ** +;Feed (ATOM) +Feed (ATOM) + + +# Translation note: ** String needs translation ** +;Archives +Archives + + +# Translation note: ** String needs translation ** +;See all headlines +See all headlines + + +# Translation note: ** String needs translation ** +;Source: +Source: + + +# Translation note: ** String needs translation ** +;You might want to install moonmoon. +You might want to install moonmoon. + + +# Translation note: ** String needs translation ** +;moonmoon installation +moonmoon installation + + +# Translation note: ** String needs translation ** +;Congratulations! Your moonmoon is ready. +Congratulations! Your moonmoon is ready. + + +# Translation note: ** String needs translation ** +;What's next? +What's next? + + +# Translation note: ** String needs translation ** +;Delete install.php with your FTP software. +Delete install.php with your FTP software. + + +# Translation note: ** String needs translation ** +;Use your password to go to the administration panel +Use your password to go to the administration panel + + diff --git a/app/l10n/extract.php b/app/l10n/extract.php old mode 100644 new mode 100755 index c63e564..1a04f00 --- a/app/l10n/extract.php +++ b/app/l10n/extract.php @@ -30,7 +30,7 @@ include_once $root . '/app/classes/Simplel10n.class.php'; function extract_l10n_strings($file) { $lines = file($file); - $patterns = array('/_g\((.*?)\)/', '/getString\((.*?)\)/', ); + $patterns = array('/_g\([\'"](.*?)[\'"]\)/', '/getString\([\'"](.*?)[\'"]\)/',); foreach ($lines as $line) { @@ -55,10 +55,10 @@ function extract_l10n_strings($file) { // Extract cleaned up strings if(count($l10n_note) == 2) { - $l10n_str = substr(trim($l10n_note[0]), 1, -1); - $l10n_note = substr(trim($l10n_note[1]), 1, -1); + $l10n_str = trim($l10n_note[0]); + $l10n_note = trim(substr(trim($l10n_note[1]),1)); # Remove quote at begining of string } else { - $l10n_str = substr(trim($val), 1, -1); # Remove quotes around the string + $l10n_str = trim($val); $l10n_note = ''; } @@ -112,7 +112,7 @@ function find_all_files($dir) { if(is_file("$dir/$value")) { $split = explode('.', $value); - if(isset($split[1]) && $split[1] == 'php'){ + if(end($split) == 'php'){ $result[] = "$dir/$value"; } continue; @@ -163,17 +163,22 @@ function update_lang_files($source, $dest) { ob_start(); foreach($GLOBALS['english'] as $key => $val) { + $warning = ''; + $value = @Simplel10n::extractString($key); + + if($value == $val[0]) { + $status[$locale]++; + $warning = ' ** String needs translation **'; + } if($val[1]) { - echo '# Translation note: ' . $val[1] . "\n"; + echo '# Translation note: ' . $val[1] . $warning . "\n"; + } elseif($warning != '') { + echo '# Translation note: ' . $warning . "\n"; } - echo ";$val[0]\n"; - $value = @Simplel10n::getString($key); + echo ";$val[0]\n"; echo $value . "\n\n\n"; - if($value == $val[0]) { - $status[$locale]++; - } } $content = ob_get_contents(); diff --git a/app/l10n/fr.lang b/app/l10n/fr.lang index 19911df..6247652 100755 --- a/app/l10n/fr.lang +++ b/app/l10n/fr.lang @@ -1,127 +1,71 @@ -;People -Personnes - -;Powered by moonmoon -Propulsé par moonmoon - -;Feed -Flux - -;Website -Site Web - -;All feeds in OPML format -Tous les flux au format OPML - -;Syndicate -Syndiquer - -;Feed (ATOM) -Flux (ATOM) - -;Archives -Archives - -;See all headlines -Afficher tous les titres - -;Source: -Source : - -;Today -Aujourd'hui - -;This week -Cette semaine - -;This month -Ce mois - -;Older items -Billets plus anciens - -;No article -Pas d'articles - -;No news, good news. -Pas de nouvelles, bonne nouvelle. - -;Go to original place -Aller à l'emplacement d'origine - -# administration panel strings below - -;moonmoon installation -Installation de moonmoon +;Are you sure you want to purge the cache? +Êtes-vous sûr de vouloir vider le cache ? -;Server is running PHP5 -Le serveur utilise PHP5 +;Clear cache +Vider le cache -;Check your server documentation to activate PHP5. -Vérifiez la documentation de votre serveur pour activer PHP5 -;%s is writable -%s est accessible en écriture +;Clear cache: +Vider le cache  : -;Make %s writable with CHMOD -Donnez les droits en écriture sur %s avec CHMOD -;Congratulations! Your moonmoon is ready. -Félicitations ! Votre moonmoon est prêt. +;Clear +Vider -;What's next? -Et maintenant  ? -;Delete install.php with your FTP software. -Effacez install.php avec votre logiciel FTP. +;Clearing the cache will make moonmoon reload all feeds. +Vider le cache forcera moonmoon à recharger tous les flux. -;Use your password to go to the administration panel -Utilisez votre mot de passe pour vous rendre sur la console d'administration +;Change administrator password +Changer le mot de passe de l'administrateur -;Feeds -Flux -;Back to main page -Retour à l'accueil +;New password: +Nouveau mot de passe  : -;moonmoon administration -Administration de moonmoon -;Logout -Déconnexion +;Change password +Changer le mot de passe -;Administration -Administration ;Add Feed Ajouter un flux + ;Link: Lien : + ;Accepted formats are RSS and ATOM. If the link is not a feed, moonmoon will try to autodiscover the feed. Les formats valides sont RSS et ATOM. Si le lien n'est pas un flux, moonmoon essaiera de trouver le flux automatiquement. + ;Manage existing feeds Gérer les flux + ;Number of feeds: %s Nombre de flux : %s + ;Save changes Enregistrer les changements + ;Delete selected Feeds Effacer les flux sélectionnés + ;Select : Sélectionner + ;All Tout + ;None Aucun @@ -129,47 +73,144 @@ Aucun ;Selection Sélection + ;Name Titre + ;Last entry Dernière entrée + ;Website link Lien du site + ;Feed link Lien du Flux + ;Not in cache Pas en cache -;Are you sure you want to purge the cache? -Êtes-vous sûr de vouloir vider le cache ? -;Clear cache: -Vider le cache  : +;Password: +Mot de passe : -;Clear cache -Vider le cache -;Clear -Vider +;OK +OK {ok} -;Clearing the cache will make moonmoon reload all feeds. -Vider le cache forcera moonmoon à recharger tous les flux. -;Change administrator password -Changer le mot de passe de l'administrateur +;moonmoon administration +Administration de moonmoon -;New password: -Nouveau mot de passe  : -;Change password -Changer le mot de passe +;Back to main page +Retour à l'accueil + + +;Logout +Déconnexion + + +;Feeds +Flux + + +;Administration +Administration {ok} + + +;Powered by moonmoon +Propulsé par moonmoon + + +;No article +Pas d'articles + + +;No news, good news. +Pas de nouvelles, bonne nouvelle. + + +;Today +Aujourd'hui + + +;Go to original place +Aller à l'emplacement d'origine + + +;This week +Cette semaine + + +;This month +Ce mois + + +;Older items +Billets plus anciens + + +;People +Personnes + + +;Feed +Flux + + +;Website +Site Web + + +;All feeds in OPML format +Tous les flux au format OPML + + +;Syndicate +Syndiquer + + +;Feed (ATOM) +Flux (ATOM) + + +;Archives +Archives{ok} + + +;See all headlines +Afficher tous les titres + + +;Source: +Source : + + +;You might want to install moonmoon. +Vous voulez probablement installer moonmoon. + + +;moonmoon installation +Installation de moonmoon + + +;Congratulations! Your moonmoon is ready. +Félicitations ! Votre moonmoon est prêt. + + +;What's next? +Et maintenant  ? + + +;Delete install.php with your FTP software. +Effacez install.php avec votre logiciel FTP. + + +;Use your password to go to the administration panel +Utilisez votre mot de passe pour vous rendre sur la console d'administration -;Password: -Mot de passe : -;OK -OK -- cgit v1.2.1