summaryrefslogtreecommitdiffstats
path: root/app/classes
diff options
context:
space:
mode:
Diffstat (limited to 'app/classes')
-rw-r--r--app/classes/PlanetConfig.php1
-rw-r--r--app/classes/Simplel10n.class.php40
2 files changed, 41 insertions, 0 deletions
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]);
+ }
+ }
+ }
+}