本文整理汇总了PHP中I18n::get方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::get方法的具体用法?PHP I18n::get怎么用?PHP I18n::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I18n
的用法示例。
在下文中一共展示了I18n::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register($userName, $email, $password, $pwdChk, &$err = null)
{
$init_err = $err;
Utils::checkEmail($email, $err);
Utils::checkPassword($password, $err);
if (strcmp($password, $pwdChk) !== 0) {
$err[] = I18n::get("error_pwd_mismatch");
}
$email = mb_strtolower($email, 'UTF-8');
$lowUsername = mb_strtolower($userName, 'UTF-8');
$others = $this->db->getUsersByUserNameOrEmail($lowUsername, $email);
if ($others) {
foreach ($others as $o) {
if (strcmp(mb_strtolower($o["username"], 'UTF-8'), $lowUsername) == 0) {
$err[] = I18n::get("error_username_already_taken");
}
if (strcmp($o["email"], $email) == 0) {
$err[] = I18n::get("error_email_already_taken");
}
}
}
if ($init_err != $err) {
return false;
}
$password = password_hash($password, PASSWORD_DEFAULT);
$this->db->createUser($userName, $email, $password);
return true;
}
示例2: message
/**
* Get a i18n message from a file. Messages are arbitary strings that are stored
* in the messages/i18/en-en, messages/i18/ru-ru directories and reference by a key.
*
* // Get "username" from messages/i18n/en-en/text.php
* $username = Ku_I18n::message('text', 'username');
*
* @uses Kohana::message
*
* @param string|array file name
* @param string key path to get
* @param string default message
* @param array array values to substititution
* @return string message string for the given path
* @return array complete message list, when no path is specified
*/
public static function message($file, $path = NULL, $default = NULL, array $values = NULL)
{
$file = (array) $file;
foreach ($file as $filename) {
$message = Kohana::message('i18n/' . I18n::$lang . '/' . $filename, $path);
if ($message === NULL) {
// Try common message
$message = Kohana::message($filename, $path);
if ($message) {
$message = I18n::get($message);
break;
}
} else {
break;
}
}
if ($message === NULL) {
// Try common message
$message = is_string($default) ? I18n::get($default) : $default;
}
if ($message and $values) {
$message = strtr($message, $values);
}
return $message;
}
示例3: __
function __($string, array $values = NULL, $lang = 'en-us')
{
if ($lang !== I18n::$lang) {
$string = I18n::get($string);
}
return empty($values) ? $string : strtr($string, $values);
}
示例4: action_index
public function action_index()
{
$photos = ORM::factory('Storage')->where('publication_id', '>', '0')->find_all();
foreach ($photos as $photo) {
if ($photo->publication_type == 'news') {
$news = ORM::factory('News', $photo->publication_id);
if ($news->loaded()) {
$title = $news->title;
}
} elseif ($photo->publication_type == 'leader') {
$page = ORM::factory('Leader', $photo->publication_id);
if ($page->loaded()) {
$title = $page->name;
}
} else {
$page = ORM::factory('Pages_content', $photo->publication_id);
if ($page->loaded()) {
$title = $page->name;
}
}
if (!isset($title)) {
$title = I18n::get("This publication is absent");
}
$photo_arr[] = array('date' => $photo->date, 'path' => $photo->file_path, 'publication_id' => $photo->publication_id, 'type' => $photo->publication_type, 'title' => $title);
}
$this->set('photos', $photo_arr);
$this->add_cumb('Photos', '/');
}
示例5: test_get
/**
* Tests i18n::get()
*
* @test
* @dataProvider provider_get
* @param boolean $input Input for File::mime
* @param boolean $expected Output for File::mime
*/
public function test_get($lang, $input, $expected)
{
I18n::lang($lang);
$this->assertSame($expected, I18n::get($input));
// Test immediate translation, issue #3085
I18n::lang('en-us');
$this->assertSame($expected, I18n::get($input, $lang));
}
示例6: __
/**
* Kohana translation/internationalization function. The PHP function
* [strtr](http://php.net/strtr) is used for replacing parameters.
*
* __('Welcome back, :user', array(':user' => $username));
*
* @uses I18n::get
* @param string text to translate
* @param array values to replace in the translated text
* @param string target language
* @return string
*/
function __($string, array $values = NULL, $lang = 'en-us')
{
if ($lang !== I18n::$lang) {
// The message and target languages are different
// Get the translation for this message
$string = I18n::get($string);
}
return empty($values) ? $string : strtr($string, $values);
}
示例7: __n
function __n($singular, $plural, $count, array $values = array())
{
if (I18n::$lang !== I18n::$default_lang) {
$string = $count === 1 ? I18n::get($singular) : I18n::get_plural($plural, $count);
} else {
$string = $count === 1 ? $singular : $plural;
}
return strtr($string, array_merge($values, array('%count' => $count)));
}
示例8: __
/**
* Kohana translation/internationalization function. The PHP function
* [strtr](http://php.net/strtr) is used for replacing parameters.
*
* __('Welcome back, :user', array(':user' => $username));
*
* [!!] The target language is defined by [I18n::$lang]. The default source
* language is defined by [I18n::$source].
*
* @uses I18n::get
* @param string text to translate
* @param array values to replace in the translated text
* @param string source language
* @return string
*/
function __($string, array $values = NULL, $source = NULL)
{
if (!$source) {
// Use the default source language
$source = I18n::$source;
}
if ($source !== I18n::$lang) {
// The message and target languages are different
// Get the translation for this message
$string = I18n::get($string);
}
return empty($values) ? $string : strtr($string, $values);
}
示例9: action_read
public function action_read()
{
$scope = Security::xss_clean($this->request->param('scope'));
$scope_category = ORM::factory('Library_Category')->where('key', '=', $scope)->find();
if (!$scope_category->loaded()) {
throw new HTTP_Exception_404();
}
if ($scope_category->published == 0) {
throw new HTTP_Exception_404();
}
$this->set('scope', $scope_category);
$id = (int) $this->request->param('id', 0);
$number = (int) Arr::get($_GET, 'chapter', 0);
$book = ORM::factory('Book', $id)->where('published', '=', 1)->and_where('show_' . I18n::$lang, '=', 1);
if (!$book->loaded()) {
throw new HTTP_Exception_404();
}
$bookprov = ORM::factory('Book', $id);
if (!$bookprov->translation(I18n::$lang)) {
throw new HTTP_Exception_404('no_translation');
//$this->redirect(URL::media(''));
}
$this->set('book', $book);
$this->add_cumb($scope_category->name, 'books/' . $scope_category->key);
$cumb = $book->title;
if ($book->author != '') {
$cumb .= '. ' . $book->author;
}
$this->add_cumb($book->category->name, 'books/' . $scope_category->key . '?category=' . $book->category->id);
$this->add_cumb($cumb, 'books/' . $scope_category->key . '/view/' . $book->id);
if ($book->type == 'pdf') {
$this->add_cumb('View', '/');
}
if ($book->type == 'txt') {
$chapters = $book->chapters->find_all();
$this->add_cumb('View', 'books/' . $scope_category->key . '/read/' . $book->id . '?chapter=' . $chapters[0]->number);
}
if ($book->type == 'txt') {
$chapter = ORM::factory('Book_Chapter')->where('number', '=', $number)->and_where('book_id', '=', $book->id)->find();
if (!$chapter->loaded()) {
throw new HTTP_Exception_404();
}
$this->set('chapter', $chapter);
$next = ORM::factory('Book_Chapter')->where('number', '>', $chapter->number)->and_where('book_id', '=', $book->id)->limit(1)->find();
if ($next->loaded()) {
$this->set('next', $next);
}
$this->add_cumb(I18n::get('Chapter') . ' ' . $chapter->number . '. ' . $chapter->title, '/');
}
}
示例10: checkUserName
public static function checkUserName($userName, $err)
{
$errors_init = $err;
if (mb_strlen($userName, 'UTF-8') < 3) {
$errors[] = I18n::get("error_username_too_short");
}
if (mb_strlen($userName, 'UTF-8') > 32) {
$errors[] = I18n::get("error_username_too_long");
}
if (!preg_match("^[a-zA-Z0-9\\-_]+\$", $userName)) {
$errors[] = I18n::get("error_username_invalid_char");
}
return $err == $errors_init;
}
示例11: action_index
public function action_index()
{
$alphabet = array('ru' => array('А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я'), 'kz' => array('А', 'Ә', 'Б', 'В', 'Г', 'Ғ', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Қ', 'Л', 'М', 'Н', 'Ң', 'О', 'Ө', 'П', 'Р', 'С', 'Т', 'У', 'Ү', 'Ұ', 'Ф', 'Х', 'Һ', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'I', 'Ь', 'Э', 'Ю', 'Я'), 'en' => array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'));
$lang = Security::xss_clean($this->request->param('language'));
foreach ($alphabet[$lang] as $alpha) {
$biog = ORM::factory('Biography')->where('published', '=', 1)->where_open()->where('name_' . $lang, 'like', $alpha . '%')->or_where('name_' . $lang, 'like', '% ' . $alpha . '%')->where_close()->find();
if ($biog->loaded()) {
$alphabet_new[] = $alpha;
}
}
$this->set('alphabet', $alphabet_new);
$categories1 = ORM::factory('Biography_Category')->where('era', '=', '1')->find_all();
$halyk_kaharmany = ORM::factory('Biography_Category', 9);
$this->set('halyk_kaharmany', $halyk_kaharmany);
$categories2 = ORM::factory('Biography_Category')->where('era', '=', '2')->find_all();
$this->set('categories1', $categories1)->set('categories2', $categories2);
$category = (int) $this->request->param('category', 0);
$alpha = Security::xss_clean($this->request->param('alpha', ""));
//SEO. закрываем сортировку
if ($alpha != '') {
$sort = 1;
Kotwig_View::set_global('sort', $sort);
}
//end_SEO
$biography = ORM::factory('Biography')->where('published', '=', 1)->where('name_' . $this->language, '<>', '');
if ($category != 0) {
$biography = $biography->where('category_id', '=', $category);
$this->add_cumb('Personalia', 'biography');
$cat = ORM::factory('Biography_Category', $category);
$this->add_cumb($cat->title, '/');
} else {
$biography = $biography->where('category_id', 'NOT IN', array(3, 4, 6, 7, 8, 15));
$this->add_cumb('Personalia', '/');
}
if (!empty($alpha)) {
$biography = $biography->where_open()->where('name_' . $lang, 'like', $alpha . '%')->or_where('name_' . $lang, 'like', '% ' . $alpha . '%')->where_close();
}
$biography = $biography->order_by('order');
$paginate = Paginate::factory($biography)->paginate(NUll, NULL, 10)->render();
$biography = $biography->find_all();
if (count($biography) == 0) {
$this->set('error', I18n::get('Sorry.'));
}
/* метатэг description */
$biography_meta = ORM::factory('Page')->where('key', '=', 'biography_' . $category . '_1')->find();
$this->metadata->description($biography_meta->description);
$this->set('list', $biography)->set('paginate', $paginate)->set('category', $category)->set('alpha', $alpha);
}
示例12: postReset
/**
* Handle a POST request to reset a user's password.
*
* @return Response
*/
public function postReset()
{
$credentials = Input::only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$user->password = Hash::make($password);
$user->save();
});
switch ($response) {
case Password::INVALID_PASSWORD:
case Password::INVALID_TOKEN:
case Password::INVALID_USER:
return Redirect::back()->with('error', I18n::get($response));
case Password::PASSWORD_RESET:
return Redirect::to('/')->with('success', 'Votre nouveau mot de passe est bien enregistré !');
}
}
示例13: actionIndex
/**
* 默认函数
*/
public function actionIndex()
{
// 多语言使用,要连数据库,表为w_language,参看enterprise数据库
// 按规定填入数据
// 使用方式
I18n::$lang = 'vi-vn';
echo I18n::get('平台管理');
// smarty模板使用方式
// {%I18n var=平台管理%}
// // 项目路径
// echo Wave::app()->projectPath;
// //当前域名
// echo Wave::app()->request->hostInfo;
// //除域名外以及index.php
// echo Wave::app()->request->pathInfo;
// //除域名外的地址
// echo Wave::app()->homeUrl;
// //除域名外的根目录地址
// echo Wave::app()->request->baseUrl;
// 关闭自动加载
// spl_autoload_unregister(array('WaveLoader','loader'));
// 开启自动加载
// spl_autoload_register(array('WaveLoader','loader'));
// $User = new User();
// echo "User model 加载成功!";
$this->username = 'Ellen';
// 然后查看 templates/site/index.html 文件
// 输出 {%$username%}
// mecache使用
// Wave::app()->memcache->set('key', '11111', 30);
// echo "Store data in the cache (data will expire in 30 seconds)";
// $get_result = Wave::app()->memcache->get('key');
// echo " Memcache Data from the cache:$get_result";
// redis使用
// Wave::app()->redis->set('key', '11111', 30);
// echo "Store data in the cache (data will expire in 30 seconds)";
// $get_result = Wave::app()->redis->get('key');
// echo " Redis Data from the cache:$get_result";
}
示例14: action_variantpublish
public function action_variantpublish()
{
$id = $this->request->param('id', 0);
$variant = ORM::factory('Test_Questvar', $id);
if (!$variant->loaded()) {
throw new HTTP_Exception_404();
}
if ($variant->published) {
$variant->published = 0;
$variant->save();
Message::success(I18n::get('Variant hided'));
} else {
$variant->published = 1;
$variant->save();
Message::success(I18n::get('Variant unhided'));
}
$this->redirect('manage/tests/variants/' . $variant->quests_id);
}
示例15: action_materials
public function action_materials()
{
if (!Auth::instance()->logged_in()) {
$this->redirect('/', 301);
}
$user_id = $this->user->id;
$materials = ORM::factory('Material')->where('user_id', '=', $user_id);
$paginate = Paginate::factory($materials)->paginate(NULL, NULL, 3)->render();
$materials = $materials->find_all();
$this->set('materials', $materials);
$this->set('paginate', $paginate);
$uploader = View::factory('storage/materials')->set('user_id', $user_id)->render();
$this->set('uploader', $uploader);
if ($this->request->method() == Request::POST) {
$journal = (int) Arr::get($_POST, 'material_type', 0);
if ($journal !== 1) {
$journal = 0;
}
try {
$material = ORM::factory('Material');
$material->theme = substr(Arr::get($_POST, 'theme', ''), 0, 250);
$material->message = substr(Arr::get($_POST, 'message', ''), 0, 500);
$material->user_id = $user_id;
$material->date = date('Y-m-d H:i:s');
$material->lang_notice = strtolower(Kohana_I18n::lang());
if ($journal) {
$material->is_journal = 1;
$material->is_moderator = 0;
}
$material->save();
$files = Arr::get($_POST, 'files', '');
if ($files) {
foreach ($files as $key => $file) {
if ($key > 7) {
break;
}
if ($file) {
$storage = ORM::factory('Storage', (int) $file);
try {
$upload = ORM::factory('Material_File');
$upload->user_id = $user_id;
$upload->material_id = $material->id;
$upload->date = date('Y-m-d H:i:s');
$upload->storage_id = (int) $file;
$upload->filesize = filesize($storage->file_path);
$upload->save();
} catch (ORM_Validation_Exception $e) {
}
}
}
}
Message::success(i18n::get('The material sent to the moderator. Thank you!'));
$user = ORM::factory('User', $user_id);
$user_email = $user->email;
Email::connect();
Email::View('review_now_' . i18N::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);
if ($journal != 1) {
$material_type = 'Интересные материалы';
$url = URL::media('/manage/materials', TRUE);
} else {
$material_type = 'Журнал e-history';
$url = URL::media('/manage/materials/ehistory', TRUE);
}
$user_profile = ORM::factory('User_Profile', $user_id);
if ($user_profile->first_name != '') {
$user_name = $user_profile->first_name . ' ' . $user_profile->last_name;
} else {
$user_name = $user->username;
}
$email = 'kaz.ehistory@gmail.com';
Email::connect();
Email::View('new_material');
Email::set(array('url' => $url, 'material_type' => $material_type, 'username' => $user_name));
Email::send($email, array('no-reply@e-history.kz', 'e-history.kz'), "Новый материал на e-history.kz", '', true);
$this->redirect('profile/materials', 301);
} catch (ORM_Validation_Exception $e) {
$errors = $e->errors($e->alias());
$files = Arr::get($_POST, 'files', '');
$this->set('errors', $errors)->set('material', $_POST)->set('files', $files);
}
}
$this->add_cumb('User profile', 'profile');
$this->add_cumb('Downloaded Content', '/');
}