www.webdeveloper.com
Results 1 to 8 of 8

Thread: Change website language content dynamically..only experts!

  1. #1
    Join Date
    May 2014
    Posts
    4

    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?

  2. #2
    Join Date
    Nov 2010
    Posts
    1,036
    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

  3. #3
    Join Date
    May 2014
    Posts
    4
    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?

  4. #4
    Join Date
    May 2014
    Posts
    4
    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

  5. #5
    Join Date
    Nov 2010
    Posts
    1,036
    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.
    Last edited by xelawho; 05-15-2014 at 08:46 PM.

  6. #6
    Join Date
    May 2014
    Posts
    4
    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?

  7. #7
    Join Date
    Nov 2010
    Posts
    1,036
    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>

  8. #8
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,264
    Read something like this for localisation (l10n) or internationalisation (l18n).
    Last edited by 007Julien; 05-18-2014 at 08:33 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles