diff options
author | Pascal Chevrel <pascal@chevrel.org> | 2012-03-12 15:40:15 +0100 |
---|---|---|
committer | Pascal Chevrel <pascal@chevrel.org> | 2012-03-12 15:40:15 +0100 |
commit | 5378cf37d8d3dde29a2e7a67e94f3966696288e6 (patch) | |
tree | d2beff7282a5e5e2ddcd870113117944587084a7 /app | |
parent | e6ab308bbdb024fe8f65f6e6419482d94dc54eab (diff) | |
download | planet-5378cf37d8d3dde29a2e7a67e94f3966696288e6.tar planet-5378cf37d8d3dde29a2e7a67e94f3966696288e6.tar.gz planet-5378cf37d8d3dde29a2e7a67e94f3966696288e6.tar.bz2 planet-5378cf37d8d3dde29a2e7a67e94f3966696288e6.tar.xz planet-5378cf37d8d3dde29a2e7a67e94f3966696288e6.zip |
l10n support for moonmoon
Diffstat (limited to 'app')
-rwxr-xr-x[-rw-r--r--] | app/app.php | 25 | ||||
-rw-r--r-- | app/classes/PlanetConfig.php | 1 | ||||
-rw-r--r-- | app/classes/Simplel10n.class.php | 40 | ||||
-rw-r--r-- | app/l10n/fr.lang | 169 |
4 files changed, 233 insertions, 2 deletions
diff --git a/app/app.php b/app/app.php index 1bb632c..d17c42e 100644..100755 --- a/app/app.php +++ b/app/app.php @@ -17,9 +17,30 @@ include_once(dirname(__FILE__).'/classes/PlanetFeed.php'); include_once(dirname(__FILE__).'/classes/PlanetItem.php'); include_once(dirname(__FILE__).'/classes/PlanetError.php'); include_once(dirname(__FILE__).'/classes/Planet.class.php'); +include_once(dirname(__FILE__).'/classes/Simplel10n.class.php'); + +$savedConfig = dirname(__FILE__).'/../custom/config.yml'; + +if (is_file($savedConfig)){ + + $conf = Spyc::YAMLLoad($savedConfig); + + // this is a check to upgrade older config file without l10n + if(!isset($conf['locale'])) { + $resetPlanetConfig = new PlanetConfig($conf); + file_put_contents($savedConfig, $resetPlanetConfig->toYaml()); + $conf = Spyc::YAMLLoad($savedConfig); + } -if (is_file(dirname(__FILE__).'/../custom/config.yml')){ - $conf = Spyc::YAMLLoad(dirname(__FILE__).'/../custom/config.yml'); $PlanetConfig = new PlanetConfig($conf); $Planet = new Planet($PlanetConfig); } + +$l10n = new Simplel10n($conf['locale']); + +// this is an helper function. We will usually use that function and not Simplel10n::getString() +function _g($str) { + return Simplel10n::getString($str); +} + + diff --git a/app/classes/PlanetConfig.php b/app/classes/PlanetConfig.php index 13e1cc6..a31938e 100644 --- a/app/classes/PlanetConfig.php +++ b/app/classes/PlanetConfig.php @@ -13,6 +13,7 @@ class PlanetConfig $defaultConfig = array( 'url' => 'http://www.example.com/', 'name' => '', + 'locale' => 'en', 'items' => 10, 'shuffle' => 0, 'refresh' => 240, diff --git a/app/classes/Simplel10n.class.php b/app/classes/Simplel10n.class.php new file mode 100644 index 0000000..cc31921 --- /dev/null +++ b/app/classes/Simplel10n.class.php @@ -0,0 +1,40 @@ +<?php + + +class Simplel10n { + + public $locale; + public $l10nFolder; + + public function __construct($locale='en') { + $GLOBALS['locale'] = array(); + $this->locale = $locale; + $this->l10nFolder = dirname(__FILE__) . '/../l10n/'; + $this->load($this->l10nFolder . $this->locale); + } + + public function setL1OnFolder($path) { + $this->l10nFolder = $path; + } + + static function getString($str) { + if(array_key_exists($str, $GLOBALS['locale'])) { + return $GLOBALS['locale'][$str]; + } else { + return $str; + } + } + + static function load($pathToFile) { + + if (!file_exists($pathToFile . '.lang')) return false; + + $file = file($pathToFile . '.lang'); + + foreach ($file as $k => $v) { + if (substr($v,0,1) == ';' && !empty($file[$k+1])) { + $GLOBALS['locale'][trim(substr($v,1))] = trim($file[$k+1]); + } + } + } +} diff --git a/app/l10n/fr.lang b/app/l10n/fr.lang new file mode 100644 index 0000000..2b933f0 --- /dev/null +++ b/app/l10n/fr.lang @@ -0,0 +1,169 @@ +;People +Personnes + +;Powered by <a %s>moonmoon</a> +Propulsé par <a %s>moonmoon</a> + +;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 + + +;Server is running PHP5 +Le serveur utilise PHP5 + +;Check your server documentation to activate PHP5. +Vérifiez la documentation de votre serveur pour activer PHP5 + +;<code>%s</code> is writable +<code>%s</code> est accessible en écriture + +;Make <code>%s</code> writable with CHMOD +Donnez les droits en écriture sur <code>%s</code> avec CHMOD + +;Congratulations! Your moonmoon is ready. +Félicitations ! Votre moonmoon est prêt. + +;What's next? +Et maintenant ? + +;<strong>Delete</strong> <code>install.php</code> with your FTP software. +<strong>Effacez</strong> <code>install.php</code> avec votre logiciel FTP. + +;Use your password to go to the <a href="./admin/">administration panel</a> +Utilisez votre mot de passe pour vous rendre sur la <a href="./admin/">console d'administration</a> + + +;Feeds +Flux + +;Back to main page +Retour à l'accueil + +;moonmoon administration +Administration de moonmoon + +;Logout +Déconnexion + +;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 + + +;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 : + +;Clear cache +Vider le cache + +;Clear +Vider + +;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 + +;New password: +Nouveau mot de passe : + +;Change password +Changer le mot de passe |