I'm currently having a regular HTML website in multiple languages. I've tried something with PHP, but that didn't turned out very well. What I need is a Multi language site without:
- Subdomains (like en.domain.tld
)
- Paths (like domain.tld/en
)
What I do need:
- Languages that are stored in sessions/cookies
- Languages which can be used around the whole site (with one place to store the language files, if that's necessary)
- Preferably without visible indications in the URL (like ?lang=en
).
A bit like how Google does it, because I also have multiple TLDs, so the user shouldn't be required to change their language by visiting another domain like .de
, if they set their language to English from the .com
site.
What is the best solution for this? I'm also very new to making websites, so that's why I'm asking.
What i prefer to do is
index.html
app.js
localization/
web-en.json
{
"title":"Hello world",
"desc":"languages are fun"
}
web-es.json
{
"title":"Hola Mundo",
"desc":"idiomas son divertidos"
}
bower install jquery-localize
Include the library
Add the attributes to your HTML tags
Hello World will go here Translated desc will replace this textCall the library onReady
$(function(){
$("[data-localize]").localize("localization/web");
};