Exemplo n.º 1
0
 function test_locale_setting_getting_deleting_methods()
 {
     !defined('AK_TEST_TRANSLATIONS')?define('AK_TEST_TRANSLATIONS',true):null;
     $translation_key=Ak::randomString(8);
     $namespace = Ak::randomString(8);
     $translation=Ak::t($translation_key,null,$namespace);
     $this->assertEqual($translation_key,$translation);
     AkLocaleManager::updateLocaleFiles();
     $dictionary = AkLocaleManager::getDictionary(AK_FRAMEWORK_LANGUAGE,$namespace);
     $this->assertEqual(array($translation_key=>$translation_key),$dictionary);
     
     $dictionary[$translation_key] = 'Spanish';
     AkLocaleManager::setDictionary($dictionary,'es',$namespace);
     $dictionary = AkLocaleManager::getDictionary('es',$namespace);
     $this->assertEqual(array($translation_key=>'Spanish'),$dictionary);
     
     Ak::t('dummy',null,$namespace);
     AkLocaleManager::updateLocaleFiles();
     $dictionary = AkLocaleManager::getDictionary(AK_FRAMEWORK_LANGUAGE,$namespace);
     $this->assertEqual(array($translation_key=>$translation_key,'dummy'=>'dummy'),$dictionary);
     
     $this->assertTrue(AkLocaleManager::deleteDictionary(AK_FRAMEWORK_LANGUAGE,$namespace));
     $this->assertEqual(array(),AkLocaleManager::getDictionary(AK_FRAMEWORK_LANGUAGE,$namespace));
     
 }
Exemplo n.º 2
0
Arquivo: Ak.php Projeto: joeymetal/v1
 /**
 * Untranslate strings from a locale to english.
 *
 * @access public
 * @static
 * @param    string    $string    The string to be untranslated.
 * @param    string    $current_language    A string containing the current language.
 * @return string The untranslated string.
 */
 public static function untranslate($string, $current_language, $namespace = false)
 {
     $dictionary = AkLocaleManager::getDictionary($current_language, $namespace);
     $untranslated_string = array_search($string, $dictionary);
     return $untranslated_string ? $untranslated_string : $string;
 }
Exemplo n.º 3
0
 static function setDictionary($dictionary, $language, $namespace = false, $comment = null)
 {
     $path = AkConfig::getDir('app') . DS . 'locales' . DS . ($namespace ? trim(Ak::sanitize_include($namespace, 'high'), DS) . DS : '') . basename($language) . '.php';
     AkLocaleManager::getDictionary($language, $namespace, true, $dictionary);
     AkFileSystem::file_put_contents($path, "<?php\n/** {$comment} */\n\n\$dictionary=" . var_export((array) $dictionary, true) . ";\n");
     return $path;
 }
Exemplo n.º 4
0
 function setDictionary($dictionary,$language,$namespace=false,$comment=null)
 {
     $path = AK_APP_DIR.DS.'locales'.DS.($namespace?trim(Ak::sanitize_include($namespace,'high'),DS).DS:'').basename($language).'.php';
     AkLocaleManager::getDictionary($language,$namespace,true,$dictionary);
     return Ak::file_put_contents($path,"<?php\n/** $comment */\n\n\$dictionary=".var_export((array)$dictionary,true).";\n");
 }