Hello!

Im looking for a new source code editor. Have come to the point where I need something more powerful and professional.

The big issue is this:

We develop software in PHP. In our code we have language specific strings like:
echo "Enter your name:";

We would like to have som nice way to handle different languages (english, italian, german, french) for strings in some kind of library.

So we easy can change the language specific part to:
echo "Inserisci il tuo nome:";

Any suggestions?

/Dan

Dani AI

Generated

Good question, . is correct that an editor won't magically translate text — you need to externalize strings and use an i18n workflow. 's simple language-file idea is a solid, pragmatic starting point; below are practical steps and pitfalls to make that approach robust and maintainable.

Use stable keys (not the English string) and group them by domain (e.g., user.name.label) so keys don't change when copy changes. Keep files per-locale in a single folder and load the correct file from a user preference, session, cookie, or explicit selector; implement a clear fallback chain (requested → session → Accept-Language → default). Store and serve everything in UTF-8 and make sure database, files and HTTP headers match.

Plan for variables and pluralization up front. Use placeholders (e.g., “Hello, {name}”) and a replacement routine rather than building strings by concatenation. For plural-sensitive text use a library or format that supports language plural rules (many languages need more than singular/plural). Cache loaded translations to avoid per-request disk I/O; show a visible placeholder or log missing keys so translators can find gaps.

Workflow matters: for small apps static PHP/JSON files are fine; for growing projects consider gettext/PO files or a translation-management workflow so translators can work on readable files without touching your codebase. Use extraction tools (or framework helpers) to keep source strings in sync, and add CI checks that flag missing or duplicate keys. Finally, prefer a tested translation helper function in PHP rather than sprinkling echoed literals — it centralizes escaping, fallback logic, and caching.

If you want, mention which frameworks or deployment size you’re targeting and the thread can outline an implementation pattern that fits your stack.

Recommended Answers

All 2 Replies

Hello Dan,

What you are describing sounds like you want an editor that shall automatically change your English prompts into other languages?

The easiest way to do this in most editors is to search (such as Ctrl + F) and then to replace all the strings with the different language.

If you mean so that on the website for different languaged users (since you're using PHP I am guessing that is what it is for) then you shall need to manually write them with a select option, the editor cannot write the code for you.

Member Avatar for Member #120589

If you have a cms - there may be an internationalization plugin - although from experience these tend to be a little flakey. You could go down the GETTEXT route, but again this is a little fiddly with having to create mo/po/pot files. The usual 'native' method is to have language files set up as arrays (or I suppose it could be done in js with json data).
e.g.

it.php

$lang = array(
    'enter_name' => 'Inserisci il tuo nome:',
    'enter_address' => 'Inserisci il tuo indirizzo:',
    ...
);

en.php

$lang = array(
    'enter_name' => 'Enter your name:',
    'enter_address' => 'Enter your address:',
    ...
);

These files can be stored in a lang folder.
Then in your pages:

$lang = 'it'; //this would be set from a cookie, post, get or session variable
include("lang/$lang.php");
...
<label for="name"><?php echo $lang['enter_name'];?></label>

Dunno if that's what you're after.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.