I18n: fix handling core mode in po2json()
This commit is contained in:
parent
ab19389d9a
commit
6a810bf75a
1 changed files with 4 additions and 3 deletions
|
@ -285,10 +285,11 @@ class I18n {
|
|||
*
|
||||
* @param string $locale The locale of the input PO file
|
||||
* @param string $path The path of the input PO file
|
||||
* @param bool $core Set to True if it's a run for core translations
|
||||
*
|
||||
* @return string JSON encoded file content
|
||||
*/
|
||||
public static function po2json($locale, $path) {
|
||||
public static function po2json($locale, $path, $core=false) {
|
||||
$fileHandler = new \Sepia\PoParser\SourceHandler\FileSystem($path);
|
||||
$poparser = new \Sepia\PoParser\Parser($fileHandler);
|
||||
$catalog = $poparser->parse();
|
||||
|
@ -305,7 +306,7 @@ class I18n {
|
|||
return json_encode(array(
|
||||
'messages' => $messages,
|
||||
'locale' => $locale,
|
||||
'domain' => self :: TEXT_DOMAIN,
|
||||
'domain' => $core?self :: CORE_TEXT_DOMAIN:self :: TEXT_DOMAIN,
|
||||
'plural_expr' => '(n > 1)',
|
||||
));
|
||||
}
|
||||
|
@ -675,7 +676,7 @@ class I18n {
|
|||
}
|
||||
|
||||
// Compile messages from PO file to JS catalog file
|
||||
$js_catalog = self :: po2json($lang, $po_file);
|
||||
$js_catalog = self :: po2json($lang, $po_file, $core_mode);
|
||||
$js_file = "$root_path/$lang.js";
|
||||
if(!$fd = fopen($js_file, 'w')) {
|
||||
Log :: error(self::_("Fail to open %s JS catalog file in write mode (%s)."),
|
||||
|
|
Loading…
Reference in a new issue