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

  • Home
  • SEARCH
  • 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 651713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:11:33+00:00 2026-05-13T22:11:33+00:00

I am using gettext in my PHP code, but I have a big problem.

  • 0

I am using gettext in my PHP code, but I have a big problem. All my JavaScript files are not affected by the translation, can somebody tell me an easy way to get the translations in the chosen language into JavaScript as well.

  • 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-13T22:11:33+00:00Added an answer on May 13, 2026 at 10:11 pm

    The easiest way is having a PHP file write the translations from gettext into JavaScript variables.

    js_lang.php:

    word_hello = "<?php echo gettext("hello"); ?>"
    word_world = "<?php echo gettext("world"); ?>"
    word_how_are_you = "<?php echo gettext("how_are_you"); ?>"
    

    and then include it:

    <script type="text/javascript" src="js_lang.php"></script>
    

    I would also recommend this method in conjunction with the translation plugins S.Mark mentions (which are very interesting!).

    You can define the dictionary in the current page’s header, too, without including an external file, but that way, you would have to look up and send the data on every page load – quite unnecessary, as a dictionary tends to change very rarely.

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

Sidebar

Related Questions

I have a PHP application using Gettext as the i18n engine. The translation works
I'm using gettext in a MAMP environment. I have locale files for es_ES ,
Is it possible to translate XSL files using PHP and gettext? I'm building a
I am using gettext for a large PHP project. I have successfully setup everything,
I have successfully set up localisation on my website using php gettext, and a
From my previous questions about gettext, one of the biggest benefits of using PHP's
I am currently translating my PHP application using gettext with POEdit. Since I respect
I can't seem to get gettext working, here. I'm using MAMP Pro and phpinfo();
I want to start using gettext to handle my translations on web projects (PHP
I'm using gettext to write a multilingual php web app. Whats the best way

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.