php gettext

gettext — Lookup a message in the current domain


// Set language to German
setlocale(LC_ALL, ‘de_DE’);
// Specify location of translation tables
bindtextdomain("myPHPApp", "./locale");
// Choose domain
// Translation is looking for in ./locale/de_DE/LC_MESSAGES/ now
// Print a test message
echo gettext("Welcome to My PHP Application");
// Or use the alias _() for gettext()
echo _("Have a nice day");

Leave a comment