summaryrefslogtreecommitdiffstats
path: root/inc/dictionary.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2014-08-15 13:10:56 +0200
committerSimon Rettberg2014-08-15 13:10:56 +0200
commitfe7412bdaf02e00699fd6654f74838c4cbe38bf9 (patch)
tree1975feb934a3d68abf2f243580cf1bd7d1c8f683 /inc/dictionary.inc.php
parent[i18n] Sanity checks, introduced subdir for template language files (diff)
downloadslx-admin-fe7412bdaf02e00699fd6654f74838c4cbe38bf9.tar.gz
slx-admin-fe7412bdaf02e00699fd6654f74838c4cbe38bf9.tar.xz
slx-admin-fe7412bdaf02e00699fd6654f74838c4cbe38bf9.zip
Find messages and hardcoded-messages in php files, fix editing of messages
Diffstat (limited to 'inc/dictionary.inc.php')
-rw-r--r--inc/dictionary.inc.php24
1 files changed, 18 insertions, 6 deletions
diff --git a/inc/dictionary.inc.php b/inc/dictionary.inc.php
index 5ac0d569..14305c99 100644
--- a/inc/dictionary.inc.php
+++ b/inc/dictionary.inc.php
@@ -3,7 +3,7 @@
class Dictionary
{
- private static $messageArray;
+ private static $messageArray = array();
private static $languages;
private static $templateCache = array();
private static $hardcodedMessages = false;
@@ -48,14 +48,18 @@ class Dictionary
}
define('LANG', $language);
- self::$messageArray = json_decode(file_get_contents("lang/" . LANG . "/messages.json"), true);
}
public static function getArrayTemplate($template, $lang = false)
{
+ return self::getArray('templates/' . $template, $lang);
+ }
+
+ public static function getArray($section, $lang = false)
+ {
if ($lang === false)
$lang = LANG;
- $file = "lang/" . $lang . "/templates/" . $template . ".json";
+ $file = Util::safePath("lang/" . $lang . "/" . $section . ".json");
if (isset(self::$templateCache[$file]))
return self::$templateCache[$file];
$language = array('lang' => $lang);
@@ -71,17 +75,25 @@ class Dictionary
public static function translate($string)
{
if (self::$hardcodedMessages === false)
- self::$hardcodedMessages = @json_decode(@file_get_contents("lang/" . LANG . "/messages-hardcoded.json"), true);
+ self::$hardcodedMessages = json_decode(file_get_contents("lang/" . LANG . "/messages-hardcoded.json"), true);
if (!isset(self::$hardcodedMessages[$string]))
return "(missing: $string :missing)";
return self::$hardcodedMessages[$string];
}
- public static function getMessages()
+ public static function getMessage($id)
{
- return self::$messageArray;
+ if (self::$messageArray === false)
+ self::$messageArray = json_decode(file_get_contents("lang/" . LANG . "/messages.json"), true);
+ if (!isset(self::$messageArray[$id]))
+ return "(missing: $id :missing)";
+ return self::$messageArray[$id];
}
+ /**
+ * Get all supported languages as array
+ * @return array List of languages (2 char id)
+ */
public static function getLanguages()
{
return self::$languages;