refs #4253 YAML format for translations
gitea/php-vn-lib/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2023-01-16 11:40:38 +01:00
parent 3a04e1fa62
commit c8a95ecaa6
3 changed files with 9 additions and 10 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
php-vn-lib (2.1.15) stable; urgency=low
php-vn-lib (2.1.16) stable; urgency=low
* Initial Release.

2
debian/control vendored
View File

@ -9,7 +9,7 @@ Vcs-Git: https://gitverdnatura.es/php-vn-lib
Package: php-vn-lib
Architecture: all
Depends: php-mysql
Depends: php-mysql, php-yaml
Section: misc
Priority: optional
Description: PHP libraries

View File

@ -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) {
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) {
$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)
&&($jsonString = file_get_contents($file)))
self::addTranslations(json_decode($jsonString, TRUE));
if (file_exists($file))
self::addTranslations(\yaml_parse_file($file));
}
/**