Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:55:04+00:00 2026-06-17T06:55:04+00:00

I am using http://jamuhl.github.com/i18next to localize a static website. My initialization script is: jQuery(function($)

  • 0

I am using http://jamuhl.github.com/i18next to localize a static website.

My initialization script is:

jQuery(function($) {
    var setLng = $.url().param('setLng');
    if (setLng)
    {
      language_complete = setLng.split("-");
    }
    else
    {
      language_complete = navigator.language.split("-");
    }
    language = (language_complete[0]);
    console.log("I speak (root): %s", language);

    i18n.init({ lng: language, debug: true }, function() {
        // save to use translation function as resources are fetched
        $(".tzm-i18n").i18n();
        $(".page-i18n").i18n();
        $(".menu-i18n").i18n();
        $(".user-i18n").i18n();
        $(".search-i18n").i18n();
        $(".footer-i18n").i18n();
    });
    // language selector
    var lngSld = false;
    $('.lng_trigger').click(function() {

And here is the HTML:

  <div id="page" class="page-i18n">
    <!--${languages} Bread crumbs -->
      <p data-i18n="welcome.p1"></p>
      <p data-i18n="welcome.p2"></p>
  </div>
  <li id="set-lang"><!-- Language selector -->
    <select id="source">
        <option selected="selected" value="br">Brasil</option>
        <option value="fr">France</option>
        <option value="de">Germany</option>
        <option value="in">India</option>
        <option value="jp">Japan</option>
        <option value="rs">Serbia</option>
        <option value="uk">United Kingdom</option>
        <option value="us">United States</option>
    </select>
  </li>

What is the correct way to set the language when <select> option is clicked and just pull the values for <p data-i18n="welcome.p1"></p> from the /locals/br/translations.json file asynchronously without having to reload the entire page?

How would this then be persisted, if the user then navigates to other pages?
I am using https://github.com/allmarkedup/jQuery-URL-Parser but don’t see any functions to alter the uri so that the choice is appended to like http://domain.tld/br/.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:55:05+00:00Added an answer on June 17, 2026 at 6:55 am

    I would put the translation functions in a separate function (i.e. translatePage()) and call it the first time during init and a second time when the click event handler is fired.

    Also, i18next comes with cookie storage (initialized with useCookie: true); you can use this to store your current language with $.i18n.setLng and retrieve it with $.i18n.lng() functions. Then it’s easy to redirect to each URI.

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using http://malsup.com/jquery/cycle/ with jquery my code is <script> $(document).ready(function(){ $(div.hide1).fadeTo(slow, 0.13); $(div.hide1).fadeTo(slow,
(using http://code.google.com/p/svgweb/ ) window.onsvgload = function() { function onEnter(e) { var targ; if (!e)
I'm using http://github.com/lakshmivyas/hyde to generate my website, and it included .htaccess mod_rewrite rules, but
I'm using http://github.com/lakshmivyas/hyde to generate my website, and it included .htaccess mod_rewrite rules, but
I'm using http://github.com/lakshmivyas/hyde to generate my website, and it included .htaccess mod_rewrite rules, but
I am using http://sharpcompress.codeplex.com/ to compress a directory: using (var archive = ZipArchive.Create()) {
I'm using http://imakewebthings.com/jquery-waypoints . I want it to fire every time a div with
I'm using http://twitter.github.com/bootstrap/javascript.html#tooltips on a app. I have this rails code: <%= link_to t('.shipping_details'),
Im using http://desandro.github.com/imagesloaded/ imagesLoaded plugin which works great for detecting when a div's images
I'm using http://github.com/bengottlieb/Twitter-OAuth-iPhone/tree/master for Twitter+Oauth in my iPhone app. I'm trying to create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.