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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:57:01+00:00 2026-05-14T21:57:01+00:00

We are in the process of making our website international, allowing multiple languages. I’ve

  • 0

We are in the process of making our website international, allowing multiple languages.

I’ve looked into php’s “gettext” however, if I understand it right, I see a big flaw:

If my webpage has let’s say “Hello World” as a static text. I can put the string as <?php echo gettext("Hello World"); ?>, generate the po/mo files using a tool. Then I would give the file to a translator to work on.

A few days later we want to change the text in English to say “Hello Small World”?
Do I change the value in gettext? Do I create an english PO file and change it there?
If you change the gettext it will consider it as a new string and you’ll instantly loose the current translation …

It seems to me that gradually, the content of the php file will have old text everywhere.
Or people translating might have to be told “when you see Hello World, instead, translate Hello Small World”.

I don’t know I’m getting confused.

In other programming languages, I’ve seen that they use keywords such as web.home.featured.HelloWorld.

What is the best way to handle translations in PHP?

Thanks

  • 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-14T21:57:01+00:00Added an answer on May 14, 2026 at 9:57 pm

    You basically asked and answered your own question, the answer might just be having a slightly better understanding of how PO files work.

    Within the PO file you have a msgid and a msgstr. The msgid is the value which is replaced with the msgstr within the PHP file depending on the localization.

    Now you can make those msgid’s anything you would like, you could very well make it:

    <?php echo _("web.home.featured.HelloWorld"); ?>
    

    And then you would never touch this string again within the source, you only edit the string through the PO files.

    So basically the answer to your question is you make the gettext values identifiers for what the string should say, however the translators typically use the default language files text as the basis for conversion, not the identifier itself.

    I hope this is clear.

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

Sidebar

Related Questions

I am in the process of making a website that involves a shopping cart.
I am currently in process of making our application Large Address Aware. As experience
I am in the process of making sure our MVC app catches all exceptions
Specifically we're making our application compatible with the Out Of Process Session State server
Our team is in the process of easing into TDD and struggling with best
Our development process is highly automated via a raft of bash and php scripts
In the process of making an old webpage standard compliant, the validator came across
I'm in the process of making a simple Todo List application based on Joosy
I'm on the process of making a dropdown widget. The menu the expands down
I'm in the process of making a Rails application be able to run on

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.