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 301215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:59:07+00:00 2026-05-12T06:59:07+00:00

I have no idea how to handle localization with JQuery. I want to set

  • 0

I have no idea how to handle localization with JQuery. I want to set an innerHTML with German text, but if the browser is configured to use English, then I want to set English text.

In PHP I use gettext for such stuff, but how to do it in JavaScript/jQuery?

  • 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-05-12T06:59:07+00:00Added an answer on May 12, 2026 at 6:59 am

    There is no easy solution for that. What I would probably do is create several scripts with language texts for every language and include proper one in PHP. So if someone is using english version of your site you would include only english file, if someone is using german version you would include german language file etc.

    Example:

    // your script logic
    myscript.js
    
    // language texts
    myscript.en.js
    myscript.de.js
    myscript.it.js
    ...
    

    You can define all language files like that:

    LANG = {
        txt1: 'English text1',
        txt2: 'English text2'
        ...
    };
    

    Make sure you are including only one of those in your HTML and make sure to include language file first i.e.

    <script type="text/javascript" src="myscript.de.js"></script>
    <script type="text/javascript" src="myscript.js"></script>
    

    Then you can use those localized texts in your main script for example:

    $(document).ready(function () {
        alert(LANG.txt1);
    });
    

    What’s best about it is that your logic (myscript.js in this example) doesn’t have to worry about localization and you won’t have to change it if you want to add a new language file.

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

Sidebar

Related Questions

I have no idea why but every 5-10 times I refresh my site in
I have no idea why but my website loads slow... I suspect there is
I have an idea for how to solve this problem, but I wanted to
I have no idea how to handle this in ColdFusion 9, I have a
I have this idea, the user defines set of css rules with some comments
I have the idea to dev a gaming server (not a mmo server, but
I try to write a daemon in python. But I have no idea how
So I have this idea of creating a asp.net user control, to handle all
I have this snippet of code in which I want to handle the downlaod
I have no idea how to handle this code within a style attribute. How

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.