/ Published in: PHP
Works, even if a locale is not avaliable on the system.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $locale = "fa"; // Define location and domain of translations $domain = 'php-addressbook'; $default_locale = $locale; // Prepare "php-gettext" require_once('gettext/gettext.inc'); // Prepare "native gettext" setup T_setlocale(LC_ALL, $locale); T_bindtextdomain($domain, $directory); T_textdomain($domain); T_bind_textdomain_codeset($domain, 'UTF-8'); echo T_gettext('ADDRESS'); if (!locale_emulation()) { print "<p>locale '$locale' is supported by your system, using native gettext implementation.</p>\n"; } else { print "<p>locale '$locale' is _not_ supported on your system, using the default locale '". $default_locale ."'.</p>\n"; } ?>