Required structure of language files

serettig's picture
Forums: 

Hi,

I'm trying to get Weblate to work with H5P libraries. Weblate is a web application through which you can coordinate localization efforts and easy to process of updating translations (it can automatically push to a fork and submit a pull request, for example). I want to improve the German localization and make it more consistent, but I think I need a tool for this to really work well, especially to achieve consistency across the many H5P libraries. (See my thoughts on a H5P tool here)

TWeblate offers many great features but I've run into one problem with it: It converts the JSON language files into an internal format to manage translations inside the platform and later convert them back to JSON. While this progress work and keeps the order and integrety of language files in general, there is one issue: empty entries in the original JSON entry file are lost because the first conversion process (original JSON -> internal format) discards empty entries (not entries with empty strings "", but fully empty objects like {})

Consider this example from .en.json:

"showWhen": {
	"rules": [
	  {}
	]
  },

The property "showWhen" on this object is fully removed in the conversion process. In semantics.json this is:

"showWhen": {
  "rules": [
	{
	  "field": "showHighlight",
	  "equals": true
	}
  ]
}

As you can see there is nothing to translate here. So the fact the Weblate removes this object doesn't delete any necessary data, but I wonder whether the empty object in the JSON language files is actually required or whether it is just an artifact that could be removed.

Note that empty objects in arrays are preserved, so the strings can still be correctly localized from a structural point of view. Some (empty) properties are missing, however.

So, these are my questions:

Would removing empty entries in language files be a problem in any way?

If this is not a functional problem: Would you accept pull requests in which these empty entries are not present? (This would lead the entries being present in some libraries on removed in others)

Sebastian

serettig's picture

You can disregard this question. I've checked all language files and the problem I mention above only occurs for my library. The language file was generated by the H5P CLI, though, but I'll simply manually remove the empty entries.

icc's picture

Yes, they can be removed unless they're part of an array([]) as the structure of the other elements would change.