$kk) self::loadFile($path); } /** * Gets the locale. * * @return string The locale with 2 digits format */ static function get() { return self::$locale; } /** * Gets the translation of a string, if no translation is found the same * string is returned. * * @param string $stringId The string to translate * @return string The translated string */ static function getString($stringId) { if (isset(self::$strings[$stringId])) return self::$strings[$stringId]; else return $stringId; } /** * Adds a path where a YAML file with translations is located. * * @param string $path The YAML file path */ static function addPath($path) { self::$paths[$path] = TRUE; if (self::$localeSet) self::loadFile($path); } /** * Loads translations from a YAML file. * * @param string $path The YAML file path */ static function loadFile($path) { $locale = self::$locale; $file = stream_resolve_include_path("$path/locale/$locale.yml"); if (file_exists($file)) self::addTranslations(\yaml_parse_file($file)); } /** * Adds a set of translations to the database. * * @param array $strings Associative array of every string and its * translation */ static function addTranslations($strings) { foreach ($strings as $string => &$translation) self::$strings[$string] = &$translation; } } }