/    Sign up×
Community /Pin to ProfileBookmark

Change website language content dynamically..only experts!

I am dealing with a moodle website which can be html code edited,I am trying to make the site change content language from english to other 3 languages, but that should happen only when smn changes the default language, i have already added a language change button to these languages. But only the menus change when i change the language button, i want the same for the contents.

I havent been able to achieve it so far, only thing i managed was to create hyper links on the home page, and only the contents changed. Is it possible to change both, menus and contents by the language button?

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@xelawhoMay 14.2014 — yes.

have you considered a google translation widget?

without seeing your page it's hard to go into any more detail, but that would be the easiest way
Copy linkTweet thisAlerts:
@Sarx85authorMay 15.2014 — I tried that but its not what I want.

Im thinking of doing this with switch or if/else, I will use a language variable and depending on the language button the browser will show the appropriate content.

Problem is, how do I tell java how to define the language button?Whats the keyword for that and how can I connect the button to javascript?
Copy linkTweet thisAlerts:
@Sarx85authorMay 15.2014 — I ve already added the language packs i want, 4 languages particularly, and there is a button on the site that changes the menus' language
Copy linkTweet thisAlerts:
@xelawhoMay 16.2014 — the button is the least of your worries, and having decided to use an if/else or switch gets you about 1% of the way to where you want to go.

the more important question would be where does the translated content come from? Do you have three separate files, with the content of the page in their respective languages? Or do you use some other automatic translation service (like google, but I guess different? And while we're on that, what is it that you want that the google widgets do not provide?)

I wouldn't put a whole lot of faith in the language packs, either, btw - if you change the language on moodle's home page you will see that only little snippets of unimportant text get translated.
Copy linkTweet thisAlerts:
@Sarx85authorMay 16.2014 — It's like that, an english company created the webpage, co-operating with companies from Spain and Italy.

Now the companies from Spain and Italy want to read the page in their own language everytime they use the language button..they ve already given us the translation, not from google.its a 3-paragraph text for each.

Can you please help me with connecting the language button to the Javascript code?

Is there a more efficient way to achieve this?
Copy linkTweet thisAlerts:
@xelawhoMay 16.2014 — well if it's only three paragraphs for each language, I wouldn't bother with any of that other stuff - just hardcode the text into the page, hide the translations with css and show them with js...

[CODE]
<head>

<title></title>
<style type="text/css">
#sp,#it{display:none}
</style>

</head>

<body>
<select id="chooser">
<option value="en">English</option>
<option value="sp">Spanish</option>
<option value="it">Italian</option>
</select>
<div id="en">This is the English content</div>
<div id="sp">Este es el contenido en español</div>
<div id="it">Questo è il contenuto Italiana</div>

<script>
(function () {
var chosen ="en";

document.getElementById("chooser").onchange = function(){
document.getElementById(chosen).style.display="none";
chosen=this.value;
document.getElementById(chosen).style.display="block";
}
})();


</script>
</body>
[/CODE]
Copy linkTweet thisAlerts:
@007JulienMay 18.2014 — Read something like this for localisation (l10n) or internationalisation (l18n).
×

Success!

Help @Sarx85 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...