theClimber

To content | To menu | To search

Tag - trics tips

Entries feed - Comments feed

Monday, September 28 2009

Setup i18n gettext in your PHP application

What is gettext and why use it?

i18n.jpg

gettext is the GNU internationalization and localization (i18n) library. It is commonly used for writing multilingual programs. It has an implementation in a lot of different languages and it's also commonly used in PHP applications.

But what does you mean by internationalisation? Actually, when you write computer code you are also going to write into your code some sentences which will be prompted to the used who is running the application. Those sentences are always written in a language of your choice. But what if that person doesn't understand that language.

The first reaction to solve this problem would be to say : "Ok, but I'm gonna make another version of the code in an other language. I'll translate all those sentences so that my application could be used by other people". And we agree, this is indeed the first solution we get. But this is not optimal since you decide to modify your intial app, you'll have to modify all the translated app too and this is not an issue. It's totally broken to work like this because it imply an enormous quantity of duplicated code and a big amount of work !

That's the moment when gettext came and solved all your problems ! Indeed, the gettext solution proposes te replace all those strings with a call to a gettext function with your sentence as parameter. This function check the chosen language and if it knows a translation of the sentence in that language, it returns the translated sentence, otherwise it returns the initial sentence.

Continue reading...

Wednesday, June 17 2009

Trics & Tips : configurer son client ssh

Flash_by_allanced.jpg

Quand vous êtes un utilisateur fréquent de machines distantes, il arrive que ça soit pratique d'optimiser un peu votre client ssh pour ne pas toujours devoir tapper une ligne de commande hyper longue, juste pour se connecter à un serveur. Si vous utilisez votre client ssh comme le commun des mortels, voici la ligne de commande que vous utilisez d'habitude :

login@hote:~> ssh login@server.domain.extension
Password:
login@server:~>

Et je vous propose d'obtenir après quelques manips :

login@hote:~> ssh server
login@server:~>

Ce qui est déjà nettement plus court, admettez-le ;)

Continue reading...