本文整理汇总了PHP中i18n::lang方法的典型用法代码示例。如果您正苦于以下问题:PHP i18n::lang方法的具体用法?PHP i18n::lang怎么用?PHP i18n::lang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类i18n
的用法示例。
在下文中一共展示了i18n::lang方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
public function before()
{
parent::before();
$this->metadata = Model::factory('Metadata');
$this->set('_metadata', $this->metadata);
Auth::instance()->auto_login();
$this->set('_language', i18n::lang());
$this->metadata->title('Вход в панель управления', false);
}
示例2: fragment_name
/**
* gets the fragment name, unique using i18n theme and skin and cat and loc
* @param string $name
* @return string
*/
public static function fragment_name($name)
{
$cat_seoname = '';
if (Model_Category::current()->loaded()) {
$cat_seoname = '_category_' . Model_Category::current()->seoname;
}
return 'fragment_' . $name . '_' . i18n::lang() . '_' . Theme::$theme . $cat_seoname;
//.Theme::$skin
}
示例3: fragment_name
/**
* gets the fragment name, unique using i18n theme and skin and cat and loc
* @param string $name
* @return string
*/
public static function fragment_name($name)
{
$cat_seoname = '';
if (Controller::$category !== NULL) {
if (Controller::$category->loaded()) {
$cat_seoname = '_category_' . Controller::$category->seoname;
}
}
$loc_seoname = '';
if (Controller::$location !== NULL) {
if (Controller::$location->loaded()) {
$loc_seoname = '_location_' . Controller::$location->seoname;
}
}
return 'fragment_' . $name . '_' . i18n::lang() . '_' . Theme::$theme . $cat_seoname . $loc_seoname;
//.Theme::$skin
}
示例4: set_filepath
public function set_filepath($filepath)
{
// Get path for possible translations
if (strrpos($filepath, "/") !== FALSE) {
$split = strrpos($filepath, "/");
$firstpart = substr($filepath, 0, $split + 1);
// The +1 to catch the /
$lastpart = substr($filepath, $split + 1);
} else {
$firstpart = "";
$lastpart = $filepath;
}
// Check whether translation exists, and load it if so
if (file_exists($firstpart . "i18n/" . i18n::lang() . "/" . $lastpart)) {
$this->_file = $firstpart . "i18n/" . i18n::lang() . "/" . $lastpart;
} elseif (file_exists($firstpart . "i18n/" . substr(i18n::lang(), 0, 2) . "/" . $lastpart)) {
$this->_file = $firstpart . "i18n/" . substr(i18n::lang(), 0, 2) . "/" . $lastpart;
} else {
$this->_file = $filepath;
}
return $this;
}
示例5:
/**
* Enable the Kohana auto-loader for unserialization.
*
* @see http://php.net/spl_autoload_call
* @see http://php.net/manual/var.configuration.php#unserialize-callback-func
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
//-- Configuration and initialization -----------------------------------------
/**
* Set the development status
*/
define('IN_DEVELOPMENT', $_SERVER['SERVER_NAME'] === 'localhost');
/**
* Sets the sites’ language
*/
i18n::$lang = 'sv-se';
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
*/
Kohana::init(array('base_url' => '/', 'index_file' => '', 'profiling' => IN_DEVELOPMENT, 'caching' => !IN_DEVELOPMENT));
/**
示例6: init
public function init()
{
// Load session handler
$this->session = Session::instance();
// Set cache handler
$this->cache = Wi3TikoCache::instance();
// Define APPRELATIVEPATH, which is the path to the application relative to the web root
// We can retrieve this by using the SCRIPT_NAME from the front-controller ({pathfromroot}/app/index.php), and extracting the path-from-root
define("APPRELATIVEPATH", substr($_SERVER["SCRIPT_NAME"], 0, strpos($_SERVER["SCRIPT_NAME"], "/app/index.php")) . "/app/latest/");
// Define document root
// TODO: Add support for ISS (see http://www.helicron.net/php/)
define("DOCUMENTROOT", $_SERVER["DOCUMENT_ROOT"] . "/");
// Determine language
$lang = Cookie::get('lang');
if ($lang !== NULL) {
if (!in_array($lang, array('nl-nl', 'en-us'))) {
// Check the allowed languages, and force the default
$lang = 'nl-nl';
}
} else {
// Language not set in cookie. Get default language from i18n file.
$i18nfiles = Kohana::find_file("config", "i18n");
if (!empty($i18nfiles)) {
$i18nsettings = Kohana::load($i18nfiles[0]);
$lang = $i18nsettings["lang"];
} else {
$lang = 'nl-nl';
// Fall back to default
}
// Save loaded language in cookie
Cookie::set('lang', $lang);
}
// Set the target language
i18n::lang($lang);
// Set the source language to some non-existing language to prevent Kohana skipping translation lookup if source and target language are identical
i18n::$source = "bb-bb";
// See http://unicode.org/cldr/utility/languageid.jsp?a=bb&l=en for valid tags
// Load wi3-kohana-specific functions
$this->kohana = new Wi3_Kohana();
// XSS Clean all user input!
// TODO: only do this if the user is not an admin...
$this->originalpost = $_POST;
// Save original $_POST
foreach ($_POST as $key => $val) {
$_POST[$key] = Security::xss_clean($val);
}
$this->originalget = $_GET;
// Save original $_GET
foreach ($_GET as $key => $val) {
$_GET[$key] = Security::xss_clean($val);
}
// Load some Wi3 classes
// Load a global database configuration
$this->database = new Wi3_Database();
// Helper functions to create databases etc
$this->globaldatabase = Wi3_Database::instance("global");
Event::instance("wi3.init.globaldatabase.loaded")->execute();
// Get routing, url and path information
// These classes in turn add a callback to the wi3.init.site.loaded Event, after which they will update with path and urls to the site
$this->routing = Wi3_Routing::instance();
Event::instance("wi3.init.routing.loaded")->execute();
$this->pathof = Wi3_Pathof::instance();
Event::instance("wi3.init.pathof.loaded")->execute();
$this->urlof = Wi3_Urlof::instance();
Event::instance("wi3.init.urlof.loaded")->execute();
// Load CSS and Javascript 'injectors'
$this->css = Wi3_Css::instance();
$this->javascript = Wi3_Javascript::instance();
// Instantiate the Model class, that is an interface to the 'factory' method for any underlying model-systems
$this->model = Wi3_Model::inst();
Event::instance("wi3.init.model.loaded")->execute();
// Instantiate the form-builder
$this->formbuilder = Wi3_Formbuilder::inst();
Event::instance("wi3.init.formbuilder.loaded")->execute();
// Now find out what is the scope of this request
// It most often is a site-scope (i.e. the admin or view of a site), but might also be a global scope (i.e. superadmin)
// This depends on the controller.
// Pagefiller-specific controllers are always for the the sitearea
$this->scope = (substr(Request::instance()->controller, 0, 9) == "adminarea" or substr(Request::instance()->controller, 0, 10) == "pagefiller" or Request::instance()->controller == "sitearea") ? "site" : "global";
if ($this->scope == "site") {
$this->sitearea = Wi3_Sitearea::inst();
// Find out what site we are working with
// Both the admin controller and the site controller need to know this in order to work properly
// Find the site by apache 'sitename' variable
if (isset($_SERVER['REDIRECT_SITENAME'])) {
$sitename = $_SERVER['REDIRECT_SITENAME'];
// With correct loading, $_SERVER['REDIRECT_SITENAME'] should always be present, as it is set in the vhosts .htaccess that redirect here
// Global site is the site in the global space, i.e. the Site model in the 'list of sites' that is always accesible
// ( In the per-site database, there can only exist one Site model )
$this->sitearea->globalsite = $this->model->factory("site")->set('name', $sitename)->load();
Event::instance("wi3.init.sitearea.globalsite.loaded")->execute();
$this->sitearea->site = $this->sitearea->globalsite;
// This site instance will be replaced by the local user site. The ->name will be added to that local site, since it does not store that in the local db
}
// If the sitename not present, the page request came here via some illegal method.
// If the site was not loaded correctly or is not active, we cannot show the site either
if (!isset($_SERVER['REDIRECT_SITENAME']) or empty($sitename) or !$this->sitearea->globalsite->loaded() or $this->sitearea->globalsite->active == FALSE) {
// Site does not exist. Quit.
throw new Kohana_Exception("site does not exist");
}
//.........这里部分代码省略.........
示例7:
<h1>Unicode Translating</h1>
<table>
<tr>
<th>Code</th>
<th>Language</th>
<th>Phrase</th>
</tr>
<?php
foreach ($cases as $lang => $name) {
i18n::$lang = $lang;
?>
<tr>
<td><?php
echo $lang;
?>
</td>
<td><?php
echo __($name);
?>
</td>
<td><?php
echo __('Hello, world');
?>
</td>
</tr>
<?php
}
?>
</table>
示例8: fragment_name
/**
* gets the fragment name, unique using i18n theme and URL
* @param string $name
* @return string
*/
public static function fragment_name($name)
{
return 'fragment_' . $name . '_' . i18n::lang() . '_' . Theme::$theme . '_' . URL::title(URL::current());
}
示例9: init
/**
* Initiate the i18n classes.
*
* Reads in and parses chosen language information set in $_SESSION['lang'].
*
* @param boolean $useCompressedLanguageFile Whether to use a single compressed language file to avoid searching for truckloads of files and boost performance.
*/
public static function init()
{
if (isset($_SESSION['lang'])) {
$tmp = self::parseLang($_SESSION['lang']);
self::$lang = $tmp[0];
self::$country = $tmp[1];
} else {
self::$lang = '';
self::$country = '';
}
if (isset($_SESSION['lang2'])) {
$tmp = self::parseLang($_SESSION['lang2']);
self::$lang2 = $tmp[0];
self::$country2 = $tmp[1];
} else {
self::$lang2 = '';
self::$country2 = '';
}
if (isset($_SESSION['lang3'])) {
$tmp = self::parseLang($_SESSION['lang3']);
self::$lang3 = $tmp[0];
self::$country3 = $tmp[1];
} else {
self::$lang3 = '';
self::$country3 = '';
}
}
示例10: setup
/**
* Initialize internationalization
* for current request
*/
public static function setup()
{
// Get language config variables
$lang_settings = self::get_language();
$lang_supported = array_keys($lang_settings['supported']);
// Get language
$lang_current = self::get_user_lang($lang_supported);
// if user language is not set
if (is_null($lang_current)) {
$lang_current = self::get_browser_preferred_language($lang_supported);
}
// if get browser language failed
if (is_null($lang_current)) {
$lang_current = $lang_settings['default'];
}
// Set user language
self::set_user_lang($lang_current);
// Set request language and locale
$lang_config = $lang_settings['supported'][$lang_current];
if (i18n::lang() !== $lang_config['code']) {
i18n::lang($lang_config['code']);
setlocale(LC_ALL, $lang_config['locale']);
}
}
示例11: die
<?php
defined('SYSPATH') or die('No direct script access.');
/**
* Initialize Kohana
*/
Kohana::init(array('charset' => 'utf-8', 'base_url' => '/ko3/'));
/**
* Enable modules.
*/
Kohana::modules(array('todoist' => MODPATH . 'todoist'));
/**
* Log all messages to files
*/
Kohana::$log->attach(new Kohana_Log_File(APPPATH . 'logs'));
/**
* Set the language to use for translating.
*/
i18n::$lang = 'en_US';
/**
* Set the routes.
*/
Route::set('test', 'test/(<controller>(/<action>))')->defaults(array('directory' => 'test', 'controller' => 'list', 'action' => 'index'));
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'welcome', 'action' => 'index', 'id' => NULL));
// Execute the main request
Request::instance($_SERVER['PATH_INFO'])->execute(FALSE);
示例12: rules
public function rules()
{
return array('title_' . i18n::lang() => array(array('not_empty')), 'storage_id' => array(array('not_empty')));
}
示例13: action_reject
public function action_reject()
{
$id = $this->request->param('id');
$material = ORM::factory('Material', $id);
if (!$material->loaded() or $material->status != 2 or $material->is_moderator == 0) {
$this->redirect('manage/materials');
}
$user_id = $material->user_id;
$lang = $material->lang_notice;
$user_email = ORM::factory('User', $user_id)->email;
$this->set('material', $material);
$token = Arr::get($_POST, 'token', false);
$return = Arr::get($_POST, 'r', 'manage/materials');
$this->set('return', Url::site($return));
if ($this->request->method() == Request::POST && Security::token() === $token) {
$message = Arr::get($_POST, 'message', '');
if ($message != '') {
$material->status = 0;
$material->mod_message = $message;
$material->moderator_id = $this->user->id;
$material->save();
$prelang = i18n::lang();
I18n::lang($lang);
Email::connect();
Email::View('review_accept_' . $lang);
Email::set(array('message' => I18n::get('Редакционной коллегией портала "История Казахстана" было отказано в публикации оставленного вами материала.')));
Email::send($user_email, array('no-reply@e-history.kz', 'e-history.kz'), I18n::get('Рассмотрение материала на портале "История Казахстана" e-history.kz'), '', true);
I18n::lang($prelang);
$this->redirect('manage/materials');
} else {
$this->set('message', $message)->set('token', Security::token(true))->set('errors', true);
}
} else {
$this->set('token', Security::token(true));
}
}
示例14:
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
*/
Kohana::init(array('base_url' => '/', 'index_file' => ''));
/**
* Sets the language to russian
*/
i18n::lang('ru');
/**
* Attach the file write to logging. Multiple writers are supported.
*/
Kohana::$log->attach(new Kohana_Log_File(APPPATH . 'logs'));
/**
* Attach a file reader to config. Multiple readers are supported.
*/
Kohana::$config->attach(new Kohana_Config_File());
/**
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array('a1' => MODPATH . 'a1', 'acl' => MODPATH . 'acl', 'a2' => MODPATH . 'a2', 'a2acldemo' => MODPATH . 'a2acldemo', 'codebench' => MODPATH . 'codebench', 'database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'orm' => MODPATH . 'orm', 'pagination' => MODPATH . 'pagination', 'userguide' => MODPATH . 'userguide'));
/**
* Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI.
示例15: test_parameter_labels
/**
* Tests Validation::errors()
*
* @test
* @covers Validation::errors
*/
public function test_parameter_labels()
{
$validation = Validation::factory(array('foo' => 'bar'))->rule('foo', 'equals', array(':value', 'something'))->label('something', 'Spanish');
$current = i18n::lang();
i18n::lang('es');
$validation->check();
$translated_expected = array('foo' => 'foo must equal Español');
$untranslated_expected = array('foo' => 'foo must equal Spanish');
$result_1 = $validation->errors('Validation', TRUE);
$result_2 = $validation->errors('Validation', 'en');
$result_3 = $validation->errors('Validation', FALSE);
// Restore the current language
i18n::lang($current);
$this->assertSame($translated_expected, $result_1);
$this->assertSame($translated_expected, $result_2);
$this->assertSame($untranslated_expected, $result_3);
}