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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:49:41+00:00 2026-05-29T03:49:41+00:00

I have a code base that can be customized for different customers. This is

  • 0

I have a code base that can be customized for different customers. This is handled, in most instances, by loading a class with constants specific to each customer, but with the same class name. Class name collision is managed, and, obviously, only one is loaded at a time.

class Customer () {
    const CUST_NAME = 'Alpha Corp.';
}

class Customer () {
    const CUST_NAME = 'Beta, Inc.';
}

For each customer, I also want the code to be internationalized. So, a program can draw its displayed text from a language-specific source, but also still be dynamic with regard to customer-specific information. Assume the customer-specific information is indifferent toward i18n. This reduces the number of files from one per customer per language, to just one per language. The desired result is to implement something similar to

// in separate language files:
$greeting = 'Hello. Welcome to ';
$greeting = 'Hola. Bienvenido a ';

// in front-end
$greeting = get $greeting in desired language;
echo $greeting, Customer::CUST_NAME, "\n";

The best solution I can devise to meet these requirements is an i18n class (or family of classes), which would handle multiple customers and/or multiple languages. However, it is execution-expensive to call methods, as opposed to string literals or constants. The methods would combine translations from constants or external sources, and combine them with values from the Customer class. (I am stuck with PHP 5.2 for now, so the niceties of heredoc for class properties/constants is unavailable.)

class i18n_en () {
    const GREETING = 'Hello. Welcome to ';

    static public function getGreeting () {
        return self::GREETING . Customer::CUST_NAME;
    }
}

Alternatively, I can write a script for a “template approach”, in which I maintain a template file of the class, with text placeholders. The customer-specific files are generated at the time of customer creation from these templates. It would be easy to generate or re-generate files as needed, but I’m back to needing a separate file for each customer for each language. Thus, it doesn’t meet my need as nicely.

Surely, I’m not the first to face this problem. Can anyone offer alternatives or best practices? Since the code will execute many times more than I’ll create a new customer, I prefer run-time efficiency to ease of maintenance. Of course, a great solution will offer both.

  • 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-29T03:49:42+00:00Added an answer on May 29, 2026 at 3:49 am

    There are two tried and true methods for PHP internationalization.

    The most prevalent is to create huge language arrays like so:

    define('MSG__GREETING', 1);
    
    $lang['en_US'] = array(MSG__GREETING => 'Hello, and welcome to ');
    $lang['fr_FR'] = array(MSG__GREETING => 'Bonjour, et bienvenue à ');
    
    $selectedLang = 'fr_FR';
    echo $lang[$selectedLang][MSG__GREETING] . 'Fhloston Paradise';
    

    Unfortunately, this gets very tedious very quickly.

    The ideal method, which I’ve used numerous times, is the accepted method of internationalization for Linux apps: il8n, via PHP’s gettext extension.

    With this method, you basically end up doing stuff like this:

    setenv('LANG=fr_FR');
    echo _('Hello, and welcome to ') . 'Fhloston Paradise';
    

    and then in il8n files (called .po) you have each translation. It’s actually much easier to maintain and extend over the long run, especially since you can just email your .po files to various translators and they just fill in the blanks, as it were… no coding skills necessary.

    Here’s a tutorial to get you started: http://kunststube.net/frontback/

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

Sidebar

Related Questions

I have this program that should execute a piece of code base on the
This is a biggie. I have a well-structured yet monolithic code base that has
I have a code base that makes extensive use of files to represent a
I have a code base that has been used as an ASP.Net web application.
I have a code-base that I'm looking to split up and add to by
is there any development environments that allow you to have one code base that
I have an existing code base that is not packaged at all. The code
I have a very large code base that contains extensive unit tests (using CppUnit).
Do you have any strategies for retrofitting unit tests onto a code base that
In my code base I find that two modules have structures with the same

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.