How to: Importing comments and LingoChecks from translation resource files

· 3 min read

When a translation resource file is uploaded to LingoHub, its content is analyzed and the translation texts are being parsed. Additionally, comments describing the translations are processed and saved. It also works in the opposite direction: the extra data added to a translation while using LingoHub is exported back as a comment preceding that translation in the resource file you download.

The comments in translation resource files are used to tell the parser to ignore something that would otherwise be parsed. They are usually added to either skip some content or to add information that describes the content. LingoHub recognizes all these comments as translation descriptions and stores them that way. At the same time it ignores the commented-out content or comments not belonging to individual translations. Proper comment syntax for each of the resource file formats were described in previous posts.

This two-way synchronization of comments allows developers to add description to any text without leaving the development environment. By the way, comments are only parsed for master locale resource files.

Adding LingoChecks to comments

Recently we introduced LingoChecks, a convenient way for developers to add more context to content that needs to be translated. LingoChecks can be set on a project level or per translation. They can also be set in the translation comments of the resource files. This way, a LingoCheck can be added at the same time a translation is added to a master locale file. It also allows a means to quickly review and change multiple LingoChecks in a resource file, and apply the update by simply uploading the file to LingoHub.

LingoChecks are extracted from the comments belonging to translations while all plain comments preceding and following the LingoCheck line are kept, and saved as the translation description. LingoCheck lines start with the lh-check keyword, followed by a curly braces block. The block contains the rules that should be applied to the translation. The individual checks start with the keyword (for example min), followed by a colon and a value for the check. If the rule being set is terms, and it has multiple values, they should be comma-separated and enclosed in brackets. If there are multiple rules present in the block, they should be comma separated and the order is not important.

  • min: value, where value can be: d, +d, -d, %d, d%, d being any positive integer
  • max: value, where possible values are the same as for min
  • placeholders: value, where value can be either true or false
  • terms: value or [value1, value2], where value can be phrase or comma separated list of phrases enclosed in brackets

Some examples of the LingoChecks syntax:

[gist: id=5143227]

The following is an example of uploading Java properties files that contain comments and LingoChecks within comments. If the iOS strings file, yaml file, Android .xml file, or any other file format that we support, was uploaded instead, the result would be very similar, the only difference being in the file syntax.

The source of the properties file that is used for this test.

[gist: id=5144025]


resource file with lingochecks import1

imported translation

If you have further questions, I am looking forward to comments. We will highlight more features in detail in upcoming blog posts.

Clock calendar notifications in harmony

Start your 14-day free trial