array('en' => 'en')); /** * Full country names * * @var array */ protected $countrylong = array('GB' => 'Britain (UK).'); /** * Full language names * * @var array */ protected $languagelong = array('en' => 'English.'); protected function __construct() { if (IdeGettext::SUPPORTED == false) { return; } // singlton } protected function __clone(){ // singlton } /** * Get an instance of IdeGettext * * @return IdeGettext */ static public function get_instance() { if (self::$instance == null) { self::$instance = new self; } return self::$instance; } /** * Get an array of installed countries * * @return array */ public function get_countries() { // get countries $countries = array(); foreach ($this->languages as $country => $languages) { $countries[] = $country; } return $countries; } /** * Get an array of installed languages for country * * @param string_type $country * @return array */ public function get_languages($country) { // get languages return $this->languages[$country]; } /** * Set gettext to langauge * * @param string $country * @param string $language */ public function set_language($country, $language) { // set language if (array_search($language,$this->languages[$country])) { $this->country = $country; $this->language = $language; $code = $language.'_'.$country; $domain = 'cycle'; bindtextdomain($domain, Ide::LOCALE_DIR); textdomain($domain); putenv("LANG=$code"); // windows is stupid and needs this trick putenv("LANGUAGE=$code"); // windows is stupid and needs this trick setlocale(LC_ALL, $code); return true; } return false; } /** * Get current language code * * @return string */ public function get_language() { return $this->language; } /** * Get language full name * * @param string $language * @return string */ public function get_language_long($language){ return $this->languagelong[$language]; } /** * Get country full name * * @param string $country * @return string */ public function get_country_long($country){ return $this->countrylong[$country]; } /** * Get current country code * * @return string */ public function get_country() { return $this->country; } } $settings = IdeIni::get_instance(); $gettext = IdeGettext::get_instance(); $country = $settings->get_value('gettext', 'country'); $language = $settings->get_value('gettext', 'language'); if (!$gettext->set_language($country, $language)) { echo sprintf(gettext('Setting language to %s_%s : failed droping to default'), $language, $country)."\n"; } else { echo sprintf(gettext('Setting language to %s_%s : sucsessful'), $language, $country)."\n"; } ?>