$lang); $content = @file_get_contents($file); if ($content === false) // File does not exist for language return $language; $json = json_decode($content, true); if (!is_array($json)) return $language; return self::$templateCache[$file] = array_merge($language, $json); } public static function translate($string) { if (self::$hardcodedMessages === false) 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 getMessage($id) { 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; } } Dictionary::init();