0

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

3
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by diafol
0

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.

1

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.