You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When having a HTML5 application and e.g. using ngx-translate as translation provider, this allows to specifcy a fallback mechanism, where in case a key is not found it falls back to the default language. Hence, if a certain value from source is not translated to a target language, this specific key should not appear in the target language's json.
This is generally the case when Template for new translations: is left open / unspecified as:
Still, an empty value can be created (despite of above's configuration) if a context once has been translated, later on the value has been deleted and saved again ( weblate). As example, the history of following value shows this case:
With this, the de.json (as per example above) ends up with an entry as following
{
"LOGIN": {
"ACTION": ""
}
}
If this de.json is provided as German translation the for LOGIN.ACTION it will display an empty string "" and fallback to English won't work.
Describe the solution you'd like
Extend the Customize JSON output addon with the following option:
The idea is that the addon can be configured (true / false) to remove keys with empty values. Furthermore, if this results in empty objects and/or lists, also those shall be removed.
With the given example above, the extended addon may needs to run several times / recursively, where the first criteria would generate:
{
"LOGIN": {
}
}
and a second run would generate:
{
}
Describe alternatives you've considered
This could be done with a post processing on the repository which receives translations from weblate by using e.g. jq, with a call similar to
jq walk(if type == "object" then with_entries(select(.value != null and .value != "" and .value != [] and .value != {})) else . end)
Drawback is, that the receiving repository needs an additional "compile" step to prepare the translation resources, and hence the json's cannot be used as delivered by Weblate, out of the box.
Hence it would be preferred, if this kind of cleaned-up output could be achieved by Weblate directly.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When having a HTML5 application and e.g. using ngx-translate as translation provider, this allows to specifcy a fallback mechanism, where in case a key is not found it falls back to the default language. Hence, if a certain value from source is not translated to a target language, this specific key should not appear in the target language's json.
This is generally the case when
Template for new translations:
is left open / unspecified as:Still, an empty value can be created (despite of above's configuration) if a context once has been translated, later on the value has been deleted and saved again ( weblate). As example, the history of following value shows this case:
With this, the
de.json
(as per example above) ends up with an entry as followingIf this
de.json
is provided as German translation the forLOGIN.ACTION
it will display an empty string""
and fallback to English won't work.Describe the solution you'd like
Extend the
Customize JSON output
addon with the following option:The idea is that the addon can be configured (
true / false
) to remove keys with empty values. Furthermore, if this results in empty objects and/or lists, also those shall be removed.With the given example above, the extended addon may needs to run several times / recursively, where the first criteria would generate:
{ "LOGIN": { } }
and a second run would generate:
Describe alternatives you've considered
This could be done with a post processing on the repository which receives translations from weblate by using e.g. jq, with a call similar to
Drawback is, that the receiving repository needs an additional "compile" step to prepare the translation resources, and hence the json's cannot be used as delivered by Weblate, out of the box.
Hence it would be preferred, if this kind of cleaned-up output could be achieved by Weblate directly.
The text was updated successfully, but these errors were encountered: