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

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 diafol

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.