Product Opener - How to update interface translations in Lang.pm

From Open Food Facts wiki
Revision as of 14:25, 9 September 2015 by Teolemon (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Project:ProductOpener > Product Opener documentation

Introduction

The translations for the strings used in Product Opener are located in Lang.pm

For Open Food Facts, the part of Lang.pm containing translations is copied in the wiki so that users can add and edit translations: http://en.wiki.openfoodfacts.org/Translations_-_Web_site_interface

This how-to explains how to push new translations from the wiki live.

Review diffs

In the wiki, use the "View history" function to review what was added / changed.

Update Lang.pm

We will be using a copy of Lang.pm:

Copy the current Lang.pm to Lang2.pm

Edit Lang2.pm and copy and paste the translations from the wiki in Lang2.pm (replacing the current translations).

Notes:

  • Lang.pm contains some code before and after the translations, keep it.
  • Make sure to use a UTF-8 editor (and that Lang2.pm character set is set to UTF-8), or you will lose special alphabets when doing the copy and paste.


Check updated Lang2.pm

Duplicate language keys

A common error is contributors who copy and paste strings to translate them, but who then forget to change the language key (e.g. "en" to the language their translating to).

A script makes sure there is only one value for each key:

stephane@ks3095298:~/product-opener/scripts$ ./check_lang_pm.pl ../cgi/Lang2.pm
Checking ../cgi/Lang2.pm
key column has 2 values for lang pt
        <<HTML
        <<HTML

-> we have twice pt => for the string "column" (side column of the web site)

Perl syntax

Lang.pm is a Perl module, the syntax needs to be correct. You can test it by running perl Lang.pm:

 perl Lang2.pm
Bareword found where operator expected at Lang2.pm line 3303, near ""Geef de ingrediënten met de vermelding "Kan"
        (Missing operator before Kan?)
Bareword found where operator expected at Lang2.pm line 3303, near "", "Geproduceerd"

Most errors are mismatched or forgotten " and ' to terminate strings, or strings that contain " or '. (use the other one for delimiters)

Restart Apache

When issues are fixed, copy Lang2.pm to Lang.pm then stop and start Apache.

sudo apache/bin/apachectl stop
sudo apache/bin/apachectl start

Note: apachectl restart does not reload preloaded Perl modules like Lang.pm, you have to stop and start.

Check that the changes are live and display correctly on the site.

Update the wiki

Any fixes you made to the Lang.pm file need to be saved immediately on the wiki.

Commit changes

For Open Food Facts, commit your changes to the git repository.