Menu

#1407 Add Moodle .php files filter

4.1
closed-fixed
None
5
2018-11-14
2018-10-24
No

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:

  • Use filter .ini with changes or configurations.
  • Using Rainbow to create an OmegaT package.

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.

Discussion

  • Aaron Madlon-Kay

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -4,34 +4,36 @@
     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 https://sourceforge.net/p/omegat/mailman/message/29061233/)
    +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](https://sourceforge.net/p/omegat/mailman/message/29061233/))
    
     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:
    +```
    +<?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.';
    +$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: https://sourceforge.net/p/omegat/mailman/message/29061233/ :
    +The two options commented in [this thread](https://sourceforge.net/p/omegat/mailman/message/29061233/):
     * Use filter .ini with changes or configurations.
     * Using Rainbow to create an OmegaT package.
    
     
  • Aaron Madlon-Kay

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -34,8 +34,9 @@
     The creation of the project is not automatic, it needs extra work.
    
     The two options commented in [this thread](https://sourceforge.net/p/omegat/mailman/message/29061233/):
    -* Use filter .ini with changes or configurations.
    -* Using Rainbow to create an OmegaT package.
    +
    +- Use filter .ini with changes or configurations.
    +- Using Rainbow to create an OmegaT package.
    
     **But both have a problem:  some keys have multi-lined values.**
    
    @@ -45,8 +46,9 @@
    
     **4: To made tests:**
     The packages of language can download here:
    -* https://download.moodle.org/langpack/3.6/
    -* https://download.moodle.org/download.php/langpack/3.6/en.zip (english, source files)
    -* https://download.moodle.org/download.php/langpack/3.6/gl.zip (galician, for example, target files)
    +
    +- https://download.moodle.org/langpack/3.6/
    +- https://download.moodle.org/download.php/langpack/3.6/en.zip (english, source files)
    +- https://download.moodle.org/download.php/langpack/3.6/gl.zip (galician, for example, target files)
    
     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.
    
     
  • Aaron Madlon-Kay

    Committed to trunk, [r10472].

     

    Related

    Commit: [r10472]

  • Aaron Madlon-Kay

    • summary: Moodle .php files filter --> Add Moodle .php files filter
    • status: open --> open-fixed
     
  • Didier Briel

    Didier Briel - 2018-11-14
    • status: open-fixed --> closed-fixed
     
  • Didier Briel

    Didier Briel - 2018-11-14

    Closed in the released version 4.1.5 update 3 of OmegaT.

    Didier

     

Log in to post a comment.