openfoodfacts / openfoodfacts-server

Open Food Facts database, API server and web interface - 🐪🦋 Perl, CSS and JS coders welcome 😊 For helping in Python, see Robotoff or taxonomy-editor
http://openfoodfacts.github.io/openfoodfacts-server/
GNU Affero General Public License v3.0
658 stars 388 forks source link

Rearchitecture of the multilingual texts / static pages #1818

Open stephanegigandet opened 5 years ago

stephanegigandet commented 5 years ago

The current system to store and serve pages like /terms-and-conditions (https://fr.openfoodfacts.org/conditions-d-utilisation in French) does not work very well with translated versions in many languages. Those texts are currently stored that way:

/lang/en/texts/terms-and-conditions.html
/lang/fr/texts/conditions-d-utilisation.html

This make translation difficult because the names are different, and the links to those texts (in the top bar for /discover and /contribute , in the footer etc.) can be broken if the file name is translated in one place and not the other.

Proposed new system:

  1. Keep the same file name for texts, and either store them in /lang/[language code]/terms-and-conditions.html or in /lang/texts/terms-and-conditions.[language code].html (or something like that)

    -> This should make it easier to generate and commit translations through Crowdin.

  2. Use a new entry in the .po files so that we can translate the text link and url:

    in fr.po:

    msgctxt text_terms_and_conditions
    msgid Terms and conditions
    msgstr Conditions d'utilisation

    That's it for the configuration. The code will use it to:

  3. Turn "Conditions d'utilisation" to the /conditions-d-utilisation url.

  4. Make /terms-of-use redirect to /conditions-d-utilisation in the correct language. (useful to keep old untranslated urls working, and to quickly find new urls)

  5. Automatically create links to Conditions d'utilisation in the menus, footer etc.

  6. Allow texts to link to other texts with just a tag like <text_link terms-and-conditions> (create the full <a href=""..>..</a> link), <text_title terms-and-conditions> and <text_url terms-and-conditions>


Also introduce support for language variants for texts:

show terms_and_conditions.pt_BR.html for Brazil, fall back to terms_and_conditions.pt if it does not exist.

Part of

teolemon commented 5 years ago

How do we handle character languages ? Automatic romanization ? Tag entries in the same file, just below the Normal text ?

stephanegigandet commented 5 years ago

We will use a new get_string_id_for_language function that normalize the string in a language specific way, it will work like entries in the taxonomy. See @hangy's https://github.com/openfoodfacts/openfoodfacts-server/pull/1696

So French will be deaccented, German won't, and CJK will be kept as-is in the URLs.

teolemon commented 2 years ago

We could use a simple Wordpress instance, with a system to sync pages to Crowdin. This works pretty well for the blog.

alexgarel commented 2 years ago

Yes I'de really advocate to choose a CMS and either proxy it from nginx or perl, but avoid re-implementing a CMS :grimacing: