-
-
Notifications
You must be signed in to change notification settings - Fork 138
Closed
Description
The method “Gettext\Generators\Jed” does not appear to create a valid Jed Json structure. For non-plural translations it returns an extra empty string in the translation array:
{
"messages": {
"orig singular 1": [
"",
"trans singular 1"
],
"orig singular 2": [
"orig plural 2",
"trans singular 2",
"trans plural 2"
]
}
}
To work properly with Jed apparently requires the following format:
{
"messages": {
"orig singular 1": [
"trans singular 1"
],
"orig singular 2": [
"trans singular 2",
"trans plural 2"
]
}
}
This patch to src/Generators/PhpArray:toArray method seems to resolve the issue:
/*
foreach ($translations as $translation) {
$key = ($translation->hasContext() ? $translation->getContext().$context_glue : '').$translation->getOriginal();
$entry = array($translation->getPlural(), $translation->getTranslation());
if ($translation->hasPluralTranslation()) {
$entry = array_merge($entry, $translation->getPluralTranslation());
}
$array[$key] = $entry;
}
*/
foreach ($translations as $translation) {
$key = ($translation->hasContext() ? $translation->getContext().$context_glue : '').$translation->getOriginal();
if ($translation->hasPluralTranslation()) {
$array[$key] = array_merge(array($translation->getTranslation()), $translation->getPluralTranslation());
} else {
$array[$key] = array($translation->getTranslation());
}
}
Doing something wrong or is a patch needed?
Metadata
Metadata
Assignees
Labels
No labels