Last modified by Vincent Massol on 2024/02/26 17:53

Show last authors
1 [[Weblate>>url:http://weblate.org/]] can be used to replace [[http:~~/~~/l10n.xwiki.org>>url:http://l10n.xwiki.org/]].
2
3 It has nice features like Github authentication and commits with the contributor's name. A list of features can be found [[here>>url:https://weblate.org/en/features/]].
4
5 The problem is that XWiki has it's own way of dealing with translation files:
6
7 * XWiki uses XML files (which isn't a standard for translation files) and java properties files
8 * XML files can contain properties (as in a java properties files) or just content
9 * Some of the keys can be marked as deprecated, and therefore be ignored
10 * Note: Single quotes have a [[special meaning in java properties files>>https://www.mscharhag.com/java/resource-bundle-single-quote-escaping]]
11
12 (((
13 = Idea =
14
15 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.
16
17 A first import script could do the following:
18
19 * Take a list of XML / properties files as an input, corresponding to the base translation file (the English one)
20 * Read the file and create a new properties file
21 ** The new file would be the same if a properties file is given except that the deprecated section will be removed/ignored
22 ** XML files with properties as content have their content extracted and are treated like a regular properties file
23 ** XML files with normal content will have two keys created: title and content, where values are the content of the corresponding tag
24 ** Make some replacement like ##''## with ##'##
25 * 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
26 ** e.g. ##.translation/xwiki-platform-core/xwiki-platform-help/xwiki-platform-help-ui/src/main/resources/Help/SupportPanel/Content_en.properties##
27 * Do the same for every other languages found for this file
28
29 This way, we can tell Weblate to look in the new directory to find translation files. We could give him this configuration for instance:
30
31 * File mask: ##.translation/xwiki-platform-core/xwiki-platform-help/xwiki-platform-help-ui/src/main/resources/Help/SupportPanel/Content_*.properties##
32 * Base file: ##.translation/xwiki-platform-core/xwiki-platform-help/xwiki-platform-help-ui/src/main/resources/Help/SupportPanel/Content_en.properties##
33 )))
34
35 After that new translations have been made from Weblate, a second script could be written for the export:
36
37 * Take the same list of translation file as the import script
38 * Search for every translation files in the ##.translation## directory, related to the base file of the list (taking all the languages)
39 * Convert them back to their original format
40 * Copy them in the right directory with the right name
41 * Commit the changes (have to check if it can be done automatically by Weblate)
42
43 (((
44 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.
45 )))

Get Connected