本文整理汇总了PHP中Ak::langs方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::langs方法的具体用法?PHP Ak::langs怎么用?PHP Ak::langs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::langs方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$this->base_dir = AK_BASE_DIR;
$this->akelos_dir = AK_FRAMEWORK_DIR;
$this->tasks_dir = AK_TASKS_DIR;
$this->has_configuration = file_exists(AkConfig::getDir('config') . DS . 'config.php');
$this->has_routes = file_exists(AkConfig::getDir('config') . DS . 'routes.php');
$this->has_database = file_exists(AkConfig::getDir('config') . DS . 'database.yml');
$this->using_root_path = $this->Request->getPath() == '/';
$this->new_install = !$this->has_configuration || !$this->has_routes || $this->using_root_path;
$this->environment = AK_ENVIRONMENT;
$this->memcached_on = AkMemcache::isServerUp();
$this->constants = AkDebug::get_constants();
$this->langs = Ak::langs();
$this->database_settings = Ak::getSettings('database', false);
$this->server_user = trim(AK_WIN ? `ECHO %USERNAME%` : `whoami`);
$this->local_ips = AkConfig::getOption('local_ips', array('localhost', '127.0.0.1', '::1'));
$paths = array(AK_APP_DIR . DS . 'locales');
$this->invalid_permissions = array();
foreach ($paths as $path) {
if (is_dir($path) && !@file_put_contents($path . DS . '__test_file')) {
$this->invalid_permissions[] = $path;
} else {
@unlink($path . DS . '__test_file');
}
}
}
示例2: testLangHasAutomaticRequirements
public function testLangHasAutomaticRequirements()
{
$this->get('/jp/person/martin')->doesntMatch();
foreach (Ak::langs() as $lang) {
$this->get("/{$lang}/person")->matches(array('lang' => $lang));
}
}
示例3: test_language_change_on_ak
public function test_language_change_on_ak()
{
$this->assertEqual(array('en', 'es'), Ak::langs());
$this->addHeader('Accept-Language: es,en-us,en;q=0.5');
$this->get($this->_test_script . 'locale_detection/get_language');
$this->assertTextMatch('es');
$this->get($this->_test_script . 'en/locale_detection/get_language/');
$this->assertTextMatch('en');
$this->get($this->_test_script . 'locale_detection/get_language');
$this->assertTextMatch('en');
}
示例4: test_language_change_on_ak
function test_language_change_on_ak()
{
$this->assertEqual(array('en', 'es'), Ak::langs());
$this->addHeader('Accept-Language: es,en-us,en;q=0.5');
$this->get(AK_TESTING_URL . '/locale_detection/get_language');
$this->assertTextMatch('es');
$this->get(AK_TESTING_URL . '/en/locale_detection/get_language/');
$this->assertTextMatch('en');
$this->get(AK_TESTING_URL . '/locale_detection/get_language');
$this->assertTextMatch('en');
}
示例5: getAvailableLocales
public function getAvailableLocales()
{
static $available_locales;
if (empty($available_locales)) {
if (defined('AK_ACTIVE_RECORD_DEFAULT_LOCALES')) {
$available_locales = Ak::stringToArray(AK_ACTIVE_RECORD_DEFAULT_LOCALES);
} else {
$available_locales = Ak::langs();
}
}
return $available_locales;
}
示例6: base_lang
function base_lang()
{
return array_shift(Ak::langs());
}
示例7: availableLocales
private function availableLocales()
{
return Ak::langs();
}
示例8: test_framework_config_locale_update
function test_framework_config_locale_update()
{
$langs=Ak::langs();
$translation_key=Ak::randomString(8);
$this->assertEqual(Ak::t($translation_key),$translation_key);
AkLocaleManager::updateLocaleFiles();
list($locales,$core_dictionary) = AkLocaleManager::getCoreDictionary(AK_FRAMEWORK_LANGUAGE);
$this->assertTrue(isset($core_dictionary[$translation_key]));
foreach($langs as $lang) {
list($locales,$core_dictionary) = AkLocaleManager::getCoreDictionary($lang);
$this->assertTrue(isset($core_dictionary[$translation_key]));
}
}
示例9: updateLocaleFiles
/**
* @todo Refactor this method
*/
function updateLocaleFiles()
{
$new_core_entries = array();
$new_controller_entries = array();
$new_controller_files = array();
$used_entries = AkLocaleManager::getUsedLanguageEntries();
require AK_CONFIG_DIR . DS . 'locales' . DS . AK_FRAMEWORK_LANGUAGE . '.php';
$core_dictionary = $dictionary;
$controllers_dictionaries = array();
foreach ($used_entries as $k => $v) {
// This is a controller file
if (is_array($v)) {
if (!isset($controllers_dictionaries[$k])) {
$controller = $k;
$module_lang_file = AK_APP_DIR . DS . 'locales' . DS . $controller . DS . AK_FRAMEWORK_LANGUAGE . '.php';
if (is_file($module_lang_file)) {
require $module_lang_file;
$controllers_dictionaries[$controller] = array_merge((array) $dictionary, (array) $v);
$existing_controllers_dictionaries[$controller] = (array) $dictionary;
} else {
$controllers_dictionaries[$controller] = (array) $v;
$new_controller_files[$controller] = $module_lang_file;
}
}
} else {
if (!isset($core_dictionary[$k])) {
$new_core_entries[$k] = $k;
}
}
}
$dictionary_file = '';
foreach ($new_controller_files as $controller => $file_name) {
$dictionary_file = "<?php\n\n// File created on: " . date("Y-m-d G:i:s", Ak::time()) . "\n\n\$dictionary = array();\n\n";
foreach ($controllers_dictionaries[$controller] as $k => $entry) {
$entry = str_replace("'", "\\'", $entry);
$dictionary_file .= "\n\$dictionary['{$entry}'] = '{$entry}';";
}
unset($controllers_dictionaries[$controller]);
$dictionary_file .= "\n\n\n?>";
Ak::file_put_contents($file_name, $dictionary_file);
}
// Module files
foreach ((array) $controllers_dictionaries as $controller => $controller_entries) {
$dictionary_file = '';
foreach ($controller_entries as $entry) {
if ($entry == '' || isset($existing_controllers_dictionaries[$controller][$entry])) {
continue;
}
$entry = str_replace("'", "\\'", $entry);
$dictionary_file .= "\n\$dictionary['{$entry}'] = '{$entry}';";
}
if ($dictionary_file != '') {
$original_file = Ak::file_get_contents(AK_APP_DIR . DS . 'locales' . DS . $controller . DS . AK_FRAMEWORK_LANGUAGE . '.php');
$original_file = rtrim($original_file, "?> \n\r");
$new_entries = "\n\n// " . date("Y-m-d G:i:s", Ak::time()) . "\n\n" . $dictionary_file . "\n\n\n?>\n";
$dictionary_file = $original_file . $new_entries;
Ak::file_put_contents(AK_APP_DIR . DS . 'locales' . DS . $controller . DS . AK_FRAMEWORK_LANGUAGE . '.php', $dictionary_file);
foreach (Ak::langs() as $lang) {
if ($lang != AK_FRAMEWORK_LANGUAGE) {
$lang_file = @Ak::file_get_contents(AK_APP_DIR . DS . 'locales' . DS . $controller . DS . $lang . '.php');
if (empty($lang_file)) {
$dictionary_file = $original_file;
} else {
$lang_file = rtrim($lang_file, "?> \n\r");
$dictionary_file = $lang_file;
}
Ak::file_put_contents(AK_APP_DIR . DS . 'locales' . DS . $controller . DS . $lang . '.php', $dictionary_file . $new_entries);
}
}
}
}
// Core locale files
$dictionary_file = '';
foreach ($new_core_entries as $core_entry) {
if ($core_entry == '') {
continue;
}
$core_entry = str_replace("'", "\\'", $core_entry);
$dictionary_file .= "\n\$dictionary['{$core_entry}'] = '{$core_entry}';";
}
if ($dictionary_file != '') {
$original_file = Ak::file_get_contents(AK_CONFIG_DIR . DS . 'locales' . DS . AK_FRAMEWORK_LANGUAGE . '.php');
$original_file = rtrim($original_file, "?> \n\r");
$new_entries = "\n\n// " . date("Y-m-d G:i:s", Ak::time()) . "\n\n" . $dictionary_file . "\n\n\n?>\n";
$dictionary_file = $original_file . $new_entries;
Ak::file_put_contents(AK_CONFIG_DIR . DS . 'locales' . DS . AK_FRAMEWORK_LANGUAGE . '.php', $dictionary_file);
foreach (Ak::langs() as $lang) {
if ($lang != AK_FRAMEWORK_LANGUAGE) {
$lang_file = Ak::file_get_contents(AK_CONFIG_DIR . DS . 'locales' . DS . $lang . '.php');
if (empty($lang_file)) {
$dictionary_file = str_replace("\$locale['description'] = 'English';", "\$locale['description'] = '{$lang}';", $original_file);
} else {
$lang_file = rtrim($lang_file, "?> \n\r");
$dictionary_file = $lang_file;
}
Ak::file_put_contents(AK_CONFIG_DIR . DS . 'locales' . DS . $lang . '.php', $dictionary_file . $new_entries);
}
//.........这里部分代码省略.........
示例10: _castToMultilingualColumn
function _castToMultilingualColumn($found, $column)
{
$columns = array();
foreach (Ak::langs() as $lang){
$columns[] = $lang.'_'.ltrim($column);
}
return $this->_setColumnDefaults($columns);
}
示例11: updateLocaleFiles
/**
* @todo Refactor this method
*/
static function updateLocaleFiles()
{
if (defined('AK_LOCALE_MANAGER') && class_exists(AK_LOCALE_MANAGER) && in_array('AkLocaleManager', class_parents(AK_LOCALE_MANAGER))) {
return;
}
$paths = array();
$new_core_entries = array();
$new_controller_entries = array();
$new_controller_files = array();
$used_entries = AkLocaleManager::getUsedLanguageEntries();
list($core_locale, $core_dictionary) = AkLocaleManager::getCoreDictionary(AK_FRAMEWORK_LANGUAGE);
$controllers_dictionaries = array();
foreach ($used_entries as $k => $v) {
// This is a controller file
if (is_array($v)) {
if (!isset($controllers_dictionaries[$k])) {
$controller = $k;
$controllers_dictionaries[$controller] = AkLocaleManager::getDictionary(AK_FRAMEWORK_LANGUAGE, $controller);
if (!empty($controllers_dictionaries[$controller])) {
$existing_controllers_dictionaries[$controller] = $controllers_dictionaries[$controller];
} else {
$new_controller_files[$controller] = true;
}
$controllers_dictionaries[$controller] = array_merge($controllers_dictionaries[$controller], (array) $v);
}
} else {
if (!isset($core_dictionary[$k])) {
$new_core_entries[$k] = $k;
}
}
}
foreach ($new_controller_files as $controller => $true) {
$paths[] = AkLocaleManager::setDictionary($controllers_dictionaries[$controller], AK_FRAMEWORK_LANGUAGE, $controller, "File created on: " . date("Y-m-d G:i:s", Ak::time()));
foreach (Ak::langs() as $lang) {
if ($lang != AK_FRAMEWORK_LANGUAGE) {
$dictionary = AkLocaleManager::getDictionary($lang, $controller);
$paths[] = AkLocaleManager::setDictionary(array_merge($controllers_dictionaries[$controller], $dictionary), $lang, $controller);
}
}
unset($controllers_dictionaries[$controller]);
}
// Module files
foreach ((array) $controllers_dictionaries as $controller => $controller_entries) {
$controller_entries = AkLocaleManager::getNewEntries($controller_entries, (array) @$existing_controllers_dictionaries[$controller]);
if (!empty($controller_entries)) {
$dictionary = AkLocaleManager::getDictionary(AK_FRAMEWORK_LANGUAGE, $controller);
$paths[] = AkLocaleManager::setDictionary(array_merge($dictionary, $controller_entries), AK_FRAMEWORK_LANGUAGE, $controller);
foreach (Ak::langs() as $lang) {
if ($lang != AK_FRAMEWORK_LANGUAGE) {
$dictionary = AkLocaleManager::getDictionary($lang, $controller);
$paths[] = AkLocaleManager::setDictionary(array_merge($dictionary, $controller_entries), $lang, $controller);
}
}
}
}
// Core locale files
$new_core_entries = AkLocaleManager::getNewEntries($new_core_entries);
if (!empty($new_core_entries)) {
AkLocaleManager::setCoreDictionary($core_locale, array_merge($core_dictionary, $new_core_entries), AK_FRAMEWORK_LANGUAGE);
foreach (Ak::langs() as $lang) {
if ($lang != AK_FRAMEWORK_LANGUAGE) {
list($l, $dictionary) = AkLocaleManager::getCoreDictionary($lang);
if (empty($l)) {
$l = $core_locale;
$l['description'] = $lang;
$l['locale_description'] = $lang;
}
if (empty($dictionary)) {
$dictionary = $core_dictionary;
}
AkLocaleManager::setCoreDictionary($l, array_merge($dictionary, $new_core_entries), $lang);
}
}
}
return $paths;
}