Moodle uses this type of files for internationalize its code.
1. Encoding of the files?
UTF-8
2. Here is the format of the filter:
The Moodle PHP files are very well written and consistent e.g. every key is separated from its value by apostrophe + closing square bracket + one space + equal sign + one space + apostrophe, and every value ends on apostrophe + semi-colon + line break (and apostrophes inside values are escaped using a back-slash). (Comment of Samuel Murray in this thread)
Here is a example:
<?php // This file is part of Moodle - http://moodle.org/ /** * Strings for component 'access', language 'en', branch 'MOODLE_36_STABLE' * * @package access * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $string['access'] = 'Accessibility'; $string['accesshelp'] = 'Accessibility help'; $string['cliunknowoption'] = 'Unrecognised options: {$a} Please use --help option.'; $string['cannotdeletemodfilter'] = 'You cannot uninstall the \'{$a->filter}\' because it is part of the \'{$a->module}\' module.';
3. Problems with others options:
The creation of the project is not automatic, it needs extra work.
The two options commented in this thread:
But both have a problem: some keys have multi-lined values.
OmegaT .ini filter could be modified, either to allow multiple line, or as a specific PHP/Moodle filter.
And we have an problem with the translation platform of Moodle (https://lang.moodle.org/). When OmegaT creates the translated files (the php files), do not must create the files with the segments without translation. If need an option similar to the options created for the .dtd and .properties files for using in Mozilla.
4: To made tests:
The packages of language can download here:
Whith the php filter, it can generate a tmx from console (align). Put this tmx file into the auto folder into tm. Generate the translated files and then compare both. The difference will be in the entries with multiple translations.
I realized a fork of the project:
* https://github.com/keko/omegat
I created a branch in my fork:
* https://github.com/keko/omegat/tree/1407-moodle-php-files-filter
I have solicited a "pull request" for integrate the filter into the project:
* https://github.com/omegat-org/omegat/pull/28
The code of the filter is adapted from the .dtd filter. It changes the pattern and some conditions in the «if» into the processFile function.
Last edit: Enrique Estévez 2018-10-24
Diff:
Diff:
Committed to trunk, [r10472].
Related
Commit: [r10472]
Closed in the released version 4.1.5 update 3 of OmegaT.
Didier