refs #4253 YAML format for translations
gitea/php-vn-lib/pipeline/head This commit looks good
Details
gitea/php-vn-lib/pipeline/head This commit looks good
Details
This commit is contained in:
parent
3a04e1fa62
commit
c8a95ecaa6
|
@ -1,4 +1,4 @@
|
||||||
php-vn-lib (2.1.15) stable; urgency=low
|
php-vn-lib (2.1.16) stable; urgency=low
|
||||||
|
|
||||||
* Initial Release.
|
* Initial Release.
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ Vcs-Git: https://gitverdnatura.es/php-vn-lib
|
||||||
|
|
||||||
Package: php-vn-lib
|
Package: php-vn-lib
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: php-mysql
|
Depends: php-mysql, php-yaml
|
||||||
Section: misc
|
Section: misc
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Description: PHP libraries
|
Description: PHP libraries
|
||||||
|
|
|
@ -61,9 +61,9 @@ namespace Vn\Lib {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a path where a JSON file with translations is located.
|
* Adds a path where a YAML file with translations is located.
|
||||||
*
|
*
|
||||||
* @param string $path The JSON file path
|
* @param string $path The YAML file path
|
||||||
*/
|
*/
|
||||||
static function addPath($path) {
|
static function addPath($path) {
|
||||||
self::$paths[$path] = TRUE;
|
self::$paths[$path] = TRUE;
|
||||||
|
@ -73,17 +73,16 @@ namespace Vn\Lib {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads translations from a JSON file.
|
* Loads translations from a YAML file.
|
||||||
*
|
*
|
||||||
* @param string $path The JSON file path
|
* @param string $path The YAML file path
|
||||||
*/
|
*/
|
||||||
static function loadFile($path) {
|
static function loadFile($path) {
|
||||||
$locale = self::$locale;
|
$locale = self::$locale;
|
||||||
$file = stream_resolve_include_path("$path/locale/$locale.json");
|
$file = stream_resolve_include_path("$path/locale/$locale.yml");
|
||||||
|
|
||||||
if (file_exists($file)
|
if (file_exists($file))
|
||||||
&&($jsonString = file_get_contents($file)))
|
self::addTranslations(\yaml_parse_file($file));
|
||||||
self::addTranslations(json_decode($jsonString, TRUE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue