Skip to content

Translating the site - ideas #1

@Yopai

Description

@Yopai

There are multiple ways to translate the site; I'll put them here to be able to have a discussion about them and we can pick one.

  1. create a static fr/index.html
    Advantages: simple, well-separated.
    Disadvantages: if it is needed to change the site structure, both files must be modified

  2. write both in the same html file, and only show one language
    Either all english, then all french;

<p lang="en">This is a wonderful site</p>
<p lang="en">A second sentence</p>
<p lang="fr">C'est un merveilleux site</p>
<p lang="fr">Une deuxième phrase</p>

Or english block, then french block

<p lang="en">This is a wonderful site</p>
<p lang="fr">C'est un merveilleux site</p>
<p lang="en">A second sentence</p>
<p lang="fr">Une deuxième phrase</p>

Advantages: All text is kept in the html file.
Disadvantages: Having both languages in the same file can be difficult to read.

  1. Put text in language javascript files
    Something like what is done here : https://medium.com/@nohanabil/building-a-multilingual-static-website-a-step-by-step-guide-7af238cc8505
in index.html:
<p data-i18n="translation-key-for-my-message">
in en.js:
{
    "translation-key-for-my-message": "This is my message";
}
in fr.js:
{
    "translation-key-for-my-message": "Ceci est mon message";
}

Advantages: Separate the HTML structure and the text; easier to translate
Disadvantages: Text is not in the HTML file anymore; we have to find a translation key for each text block

Using Javascript also mean two possibilities :

  • either we have two different urls, both able to be indexed by the search engines
  • or we have only one public url, other languages are only available through Javascript (hence, not indexed by the search engines)

What do you think ? Which one of these do you prefer ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions