Hello Team
I found your i18next module recently and I'm trying to use it for personal purpose. First of all, thank your for your great job you have done with your module.
I've successfully tried to use it in the server-side and It works perfectly.
Now, I'm trying to use it in the client-side and I unfortunetly don't understand how it must works. I read all the documentation in the i18next.com web site and I didn't find (or understand) a way to use 18next module in the client side. I cannot find enough documentation to use your module in HTML files and I was wondering if you could help me.
Here is what I'm trying to do:
I have the following HTML web site:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<script type="text/javascript" src="lib/i18next.js"></script>
<script>
window.onload = function() {
i18next.init({
load:['en-US', 'fr', 'es'],
fallbackLng: 'en-US',
ns:'Web_Server',
defaultNS:'Web_Server',
backend: {
loadPath: '/language/static/{{lng}}/{{ns}}.json'
},
getAsync:false
},function(t) {
var translate = i18next.t("Hello");
console.log("translate variable = " + translate);
});
};
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My First Translated Page</title>
<link rel="stylesheet" href="lib/bootstrap-3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="lib/bootstrap-3.1.1/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/style.css"/>
</head>
<body background="./img/MS_homepageNEW_bg3.jpg">
<font color="yellow">
<h1 align="center"> Welcome to My Web Server !!! <br><br> </h1>
</font>
<p style="text-align:center"><img src = "img/Family.jpg"> </img></p>
<font color="yellow">
<h2 align="center"> <br> <br> Choose your favorite application: </h2>
</font>
<p style="text-align:center">
<button type="button" class="btn btn-success"> <a href="/user/login"> Application <br> by Me</a></button>
<button type="button" class="btn btn-warning divider"> <a href="/user/#/RECEPTION"> WebMail <br> by User 2 </button>
</p>
</body>
</html>
The following section:
<script type="text/javascript" src="lib/i18next.js"></script>
<script>
window.onload = function() {
i18next.init({
load:['en-US', 'fr', 'es'],
fallbackLng: 'en-US',
ns:'Web_Server',
defaultNS:'Web_Server',
backend: {
loadPath: '/language/static/{{lng}}/{{ns}}.json'
},
getAsync:false
},function(t) {
var translate = i18next.t("Hello");
console.log("translate variable = " + translate);
});
};
</script>
is what I tried to do (by searching examples on google) but when I execute that, the "Hello" string I'm trying to translate has the same value when executing the web page (So the string is not translated and I get in return the original string).
Can you please tell me what i'm doing wrong or what I have to do to get it work ? Must I install some module in the server side ? Is it possible to store the translations in the client side and if yes, how to do it and how to access to these translations ?
What configuration (server-side or client-side) i must have to be able, in my html example, to translate the strings (like for example the string in the title of the html page "My First Translated Page", and so on)? I have already the translated strings in json format. As I said, I can easily translate strings in the server-side.
Thank you very much for your help.