How to check placeholders integrity in translations

How to check placeholders integrity in translations

by German Valero -
Number of replies: 8
Picture of Language pack maintainers

Hi David,

I have a recurring nightmare about placeholders in the original English language strings that I had inadvertingly mis-translated; either by ignorance when I began translating in AMOS or by genuine typing errors as a mere human being.


Is there a regex instruction that will allow me/anybody to check that all strings for one branch of my/any language pack have indeed all original English language placeholders properly respected in the translation ?


Thanks in advance for your help.

In reply to German Valero

Re: How to check placeholders integrity in translations

by David Mudrák -
Picture of Language pack maintainers

Hi German

no, there is no such feature available yet in AMOS. I was thinking about it long time ago and it seemed to me that there should be both

  • report that would check for the consistency between the placeholders in the English text and the translated text - so that all {$a} and {$a->something} placeholders in English are present in the translation, and nothing is added extra there
  • immediate check done when the string is translated and staged (the background turns blue) and eventually a warning is raised.

Only in a very few cases, the difference between English and the translation is expected. Missing placeholders can lead to serious bugs actually - such as MDL-37235 or MDL-51405.

German, please report this feature request as a new MDLSITE issue, component lang.moodle.org. Thanks in advance.

In reply to David Mudrák

Re: How to check placeholders integrity in translations

by German Valero -
Picture of Language pack maintainers

Hi David,

I just created MDL-51775 . Please change whatever might be neeeded in the issue description/location/....

Would it be useful to contact Köen and other AMOS translators about this issue?

Thanks again for your help.

In reply to German Valero

Er: Re: How to check placeholders integrity in translations

by José Miguel Andonegi Martínez -

Hi German:

I use this trick to check for integrity:

  1. Load the language pack in la local instance of Moodle
  2. Load the language pack in the custom translation tool
  3. Run the sql instance in the attached file (tm_generator.txt)
  4. Insert the result of the query in template.tmx file

The result is a translation memory that can be analysed  with Checkmate.

The problem: probably you will get many errors due to some characters that are not allowed by Checkmate so you will have to remove manually some translation units. After doing it, you will get a report with some possible errors (see the attached image).

Of course, it would be great to have an integrated quality check system in Moodle.

Attachment kate_susmagarria.gif
In reply to José Miguel Andonegi Martínez

Re: Er: Re: How to check placeholders integrity in translations

by German Valero -
Picture of Language pack maintainers
Thanks José Miguel.

I'll try it later in my local server.

Can you please check the documentation for doing this at https://docs.moodle.org/dev/Translation_FAQ#Is_there_a_way_to_check_the_integrity_of_all_placeholders_in_a_language_pack.3F and expand/correct/change as needed?

May I assume that you have already checked and fixed the international spanish language pack for 2.9 ?

Thanks a lot.
In reply to German Valero

Er: Re: Er: Re: How to check placeholders integrity in translations

by José Miguel Andonegi Martínez -

Hi German:

I have just seen your message. It's nice to see the post in the FAQ area. smile

I have just updated the tutorial. Now it's here.

Regards!

In reply to José Miguel Andonegi Martínez

Er: Re: Er: Re: How to check placeholders integrity in translations

by José Miguel Andonegi Martínez -

Hi German:

I just had a quick look to the international Spanish Language pack. It has the logical problems derived from human errors (the same ones I found in the Basque language pack).

Some examples:

  • Some texts use entities (for instance  ). This kind of pre-UTF8 characters are allowed for HTML but not for XML. In a proper TM, they are removed, so, you could do it with a text editor Search and Replace utility (I use Notepad++). May be we could avoid using entities and change those texts (some of them are in the original English text) but I don't think it is a big problem.
  • You will get errors derived from unclosed tags (for instance missing </p>)
  • I have seen many tags like this: <P>Example</P> I am not sure if it is valid, but I would change them (see this post) .
  • You will get an error in Checkmate if you open a tag in uppercase and close it lowercase.

I did that cleaning in Basque language pack (and in some few wrong source English texts) and I encourage to do it in other language packs as well.

Regards!

In reply to José Miguel Andonegi Martínez

Er: Re: Er: Re: How to check placeholders integrity in translations

by José Miguel Andonegi Martínez -

I have updated the tutorial. Now it also explains how to get the language pack as a spreadsheet.

Regards!