summaryrefslogtreecommitdiffstats
path: root/common/app/classes/Simplel10n.class.php
diff options
context:
space:
mode:
authorDamien Lallement <dams@mageia.org>2012-08-13 10:45:23 +0000
committerDamien Lallement <dams@mageia.org>2012-08-13 10:45:23 +0000
commitff32e499745367b816d10f25e63ff3328214c32f (patch)
tree238d19398f5951d69d32c8ed9a460f5193446981 /common/app/classes/Simplel10n.class.php
parent5bed2fb79d7b554dd90d2eb58422cfa649aebe08 (diff)
downloadplanet-ff32e499745367b816d10f25e63ff3328214c32f.tar
planet-ff32e499745367b816d10f25e63ff3328214c32f.tar.gz
planet-ff32e499745367b816d10f25e63ff3328214c32f.tar.bz2
planet-ff32e499745367b816d10f25e63ff3328214c32f.tar.xz
planet-ff32e499745367b816d10f25e63ff3328214c32f.zip
- Import moonmoon
- Create repo per langs
Diffstat (limited to 'common/app/classes/Simplel10n.class.php')
-rwxr-xr-xcommon/app/classes/Simplel10n.class.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/common/app/classes/Simplel10n.class.php b/common/app/classes/Simplel10n.class.php
new file mode 100755
index 0000000..7af8564
--- /dev/null
+++ b/common/app/classes/Simplel10n.class.php
@@ -0,0 +1,52 @@
+<?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, $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 {
+ 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]);
+ }
+ }
+ }
+}