-
Notifications
You must be signed in to change notification settings - Fork 1
Description
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.
-
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 -
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.
- 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 ?