Exemplo n.º 1
0
 public function test_listTranslation()
 {
     $list = USVN_Translation::listTranslation();
     $this->assertTrue(in_array('fr_FR', $list));
     $this->assertTrue(in_array('en_US', $list));
     $this->assertFalse(in_array('.', $list));
     $this->assertFalse(in_array('..', $list));
     $this->assertFalse(in_array('.svn', $list));
 }
Exemplo n.º 2
0
 /**
  * Set default language in the config file
  *
  * @param string The default language
  * @throw USVN_Exception
  */
 public static function setLanguage($language)
 {
     if (in_array($language, USVN_Translation::listTranslation())) {
         $config = new USVN_Config_Ini(USVN_CONFIG_FILE, USVN_CONFIG_SECTION);
         $config->translation->locale = $language;
         $config->save();
     } else {
         throw new USVN_Exception(T_("Invalid language"));
     }
 }
Exemplo n.º 3
0
 /**
  * This method will  write the choosen language into config file.
  *
  * Throw an exception in case of problems.
  *
  * @param string Path to the USVN config file
  * @param string Language
  * @throw USVN_Exception
  */
 public static function installLanguage($config_file, $language)
 {
     if (in_array($language, USVN_Translation::listTranslation())) {
         $config = Install::_loadConfig($config_file);
         $config->translation = array('locale' => $language);
         $config->save();
     } else {
         throw new USVN_Exception(T_('Invalid language'));
     }
 }