Feature
 Completed
 

https://markmail.org/message/qjek4junodom3z6x
https://markmail.org/message/273o2cqojgzpsh7t

 

http://design.xwiki.org/xwiki/bin/view/Proposal/MigratetranslationtoadedicatedtoolTranslationservic

Description

Weblate can be used to replace http://l10n.xwiki.org.

It has nice features like Github authentication and commits with the contributor's name. A list of features can be found here

The problem is that XWiki has it's own way of dealing with translation files:

  • XWiki uses XML files (which isn't a standard for translation files) and java properties files
  • XML files can contain properties (as in a java properties files) or just content
  • Some of the keys can be marked as deprecated, and therefore be ignored
  •  Note: Single quotes have a special meaning in java properties files

Idea

Weblate is able to run scripts after pulling changes from the git repository and before committing changes. That way we can write some scripts to deal with the problem that we are facing.

A first import script could do the following:

  • Take a list of XML / properties files as an input, corresponding to the base translation file (the English one)
  • Read the file and create a new properties file
    • The new file would be the same if a properties file is given except that the deprecated section will be removed/ignored
    • XML files with properties as content have their content extracted and are treated like a regular properties file
    • XML files with normal content will have two keys created: title and content, where values are the content of the corresponding tag
    • Make some replacement like '' with '
  • Place the new file in a hidden directory (.translation for instance) with the same directory as the initial one and name it as shown bellow
    • e.g. .translation/xwiki-platform-core/xwiki-platform-help/xwiki-platform-help-ui/src/main/resources/Help/SupportPanel/Content_en.properties
  • Do the same for every other languages found for this file

This way, we can tell Weblate to look in the new directory to find translation files. We could give him this configuration for instance:

  • File mask: .translation/xwiki-platform-core/xwiki-platform-help/xwiki-platform-help-ui/src/main/resources/Help/SupportPanel/Content_*.properties
  • Base file: .translation/xwiki-platform-core/xwiki-platform-help/xwiki-platform-help-ui/src/main/resources/Help/SupportPanel/Content_en.properties

After that new translations have been made from Weblate, a second script could be written for the export:

  • Take the same list of translation file as the import script
  • Search for every translation files in the .translation directory, related to the base file of the list (taking all the languages)
  • Convert them back to their original format
  • Copy them in the right directory with the right name
  • Commit the changes (have to check if it can be done automatically by Weblate)

The script could be written in Python, as it's the language used by Weblate (so we won't have much dependencies problem) and is relatively quite used for this type of work.


 


Tags:
Created by Adel Atallah on 2018/04/23 11:55
    

Get Connected