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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:42:14+00:00 2026-06-13T16:42:14+00:00

I have my php gettext default language in English let’s say I would like

  • 0

I have my php gettext default language in English let’s say

I would like in one of my controller, to translate some words in 2 other languages and put them all in an array.

ideally I could do

$word_sv = gettext($word, 'sv_SV');
$word_fi = gettext($word, 'fi_FI');

but it doesn’t exist.

Is the only way to change the overall gettext settings each time?

function setLang($lang){
    putenv("LC_ALL=$lang");
    setlocale(LC_ALL, $lang);
    bindtextdomain("myPHPApp", "./locale");
    textdomain("myPHPApp");
}

setLang('sv_SV');
$word_sv = gettext($word);
setLang('fi_FI');
$word_fi = gettext($word);

related: saw it on Google after : i18n with gettext but without the locale hassle?


Edit

here are the proposed answered solutions:

  • https://github.com/Philipp15b/php-i18n (seems best solution)
  • http://glotpress.trac.wordpress.org/browser/trunk/pomo (could use it if I find a good doc or tuto ;))
  • change locale on the fly, probably not good
  • 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-13T16:42:16+00:00Added an answer on June 13, 2026 at 4:42 pm

    I know the pains of using gettext, but its performance is what keeps me with it !

    In your case, you might want to look at this little project ? i’m pretty sure this might help you !

    this simply uses .ini files with translations, you can freely switch between files and echo the different languages for the same word.

    https://github.com/Philipp15b/php-i18n

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

Sidebar

Related Questions

I have php scripts that do things like register, login, upload. I would like
I am using gettext in my PHP code, but I have a big problem.
I have php code that puts some values into an Array as follows: $hunter=addslashes($MessageArray[1]);
I have PHP script works without problems, like this : while($row4 = mysql_fetch_array($result4)) {
I have PHP snippets like this ( snippet.php ): <?php $some_param = some_function(); ?>
I have PHP scrip that goes like this: if ($cost_frm < $cost){ echo <script
I am writing an PHP application and using the gettext module to translate to
I have created a language file in poedit for the use of the PHP
I have a PHP application using Gettext as the i18n engine. The translation works
I have a linux server with PHP. I do not see gettext in the

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.