本文整理汇总了PHP中I18n::find方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::find方法的具体用法?PHP I18n::find怎么用?PHP I18n::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I18n
的用法示例。
在下文中一共展示了I18n::find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __
/**
* Global Translation/internationalization function.
* Accepts an English string and returns its translation
* to the active system language. If the given string is not available in the
* current dictionary the original English string will be returned.
*
* <code>
* // Display a translated message
* echo __('Hello, world', 'namespace');
*
* // With parameter replacement
* echo __('Hello, :user', 'namespace', array(':user' => $username));
* </code>
*
* @global array $dictionary Dictionary
* @param string $string String to translate
* @param array $values Values to replace in the translated text
* @param string $namespace Namespace
* @return string
*/
function __($string, $namespace = null, array $values = null)
{
// Redefine arguments
$string = (string) $string;
// Find string in dictionary
$string = I18n::find($string, $namespace);
// Return string
return empty($values) ? $string : strtr($string, $values);
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$navigation = Nav::find($id);
if (empty($navigation)) {
return Redirect::to('admin/navigation')->with('success', Lang::get('admin.navigation_notfind'));
}
$rules = array();
$navigation_name_locales = array();
foreach (Input::except('_token') as $k => $v) {
if (strpos($k, 'navigation_title_') !== false) {
$rules[$k] = Config::get('validator.admin.navigation_title.title');
$navigation_name_locales[] = mb_substr($k, strlen('navigation_title_'), strlen($k) - strpos($k, 'navigation_title_'));
}
}
$rules = array_merge($rules, Config::get('validator.admin.navigation'));
//return var_dump($rules);
// Validate the inputs
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
//Update translations
foreach ($navigation_name_locales as $locale) {
if (!I18n::find($navigation->i18n_title)->updateText($locale, Input::get('navigation_title_' . $locale))) {
return Redirect::to('admin/navigation')->with('error', Lang::get('admin.navigation_update_error'));
}
}
/*
if (Input::has('parent_id')) {
$navigation->parent_id = Input::get('parent_id');
} else {
$navigation->parent_id = 0;
}
*/
if (Input::has('url_external')) {
//create a link and put the id in the navigable_id :)
$nav_link = NavLink::find($navigation->navigable_id);
$nav_link->url = Input::get('url_external');
$nav_link->save();
}
if (Input::has('model_resource_id')) {
$result_explode = explode('|', Input::get('model_resource_id'));
$navigation->navigable_id = $result_explode[1];
$navigation->navigable_type = $result_explode[0];
}
if (Input::has('order')) {
$navigation->order = Input::get('order');
} else {
$navigation->order = Nav::max() + 1;
}
// Was the blog post created?
if ($navigation->save()) {
//track user
parent::track('update', 'Navigation', $navigation->id);
Cache::forget('DB_Nav');
// Redirect to the new blog post menu
return Redirect::to('admin/navigation')->with('success', 'Le menu à bien été modifié !');
}
// Redirect to the blog post edit menu
return Redirect::to('admin/navigation/' . $id . '/edit')->with('error', 'Le menu n\'a pas pu être modifiée...');
}
// Form validation failed
return Redirect::to('admin/navigation/' . $id . '/edit')->withInput()->withErrors($validator);
}
示例3: postOption
/**
* post All Option in base
*
* @return Response
*/
public function postOption()
{
//Making adaptive rules for site_name
$site_name_rules = array();
$site_name_locales = array();
foreach (Input::all() as $k => $v) {
if (strpos($k, 'site_name_') !== false) {
$site_name_rules[$k] = Config::get('validator.admin.option_site_name');
$site_name_locales[] = mb_substr($k, strlen('site_name_'), strlen($k) - strpos($k, 'site_name_'));
}
}
//Making adaptive rules for social_title
$social_title_rules = array();
$social_title_locales = array();
foreach (Input::all() as $k => $v) {
if (strpos($k, 'social_title_') !== false) {
$social_title_rules[$k] = Config::get('validator.admin.option_social_title');
$social_title_locales[] = mb_substr($k, strlen('social_title_'), strlen($k) - strpos($k, 'social_title_'));
}
}
//Making adaptive rules for social_description
$social_description_rules = array();
$social_description_locales = array();
foreach (Input::all() as $k => $v) {
if (strpos($k, 'social_description_') !== false) {
$social_description_rules[$k] = Config::get('validator.admin.option_social_description');
$social_description_locales[] = mb_substr($k, strlen('social_description_'), strlen($k) - strpos($k, 'social_description_'));
}
}
$rules = array_merge($site_name_rules, $social_title_locales, $social_description_locales, Config::get('validator.admin.option'));
// Validate the inputs
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes()) {
//Themes
$activeThemePublic = Theme::where('type', 'public')->where('active', 1)->first();
$activeThemeAdmin = Theme::where('type', 'admin')->where('active', 1)->first();
//Change or not?
if ($activeThemePublic->id != Input::get('theme_public')) {
$activeThemePublic->active = false;
$activeThemePublic->save();
$newThemePublic = Theme::find(Input::get('theme_public'));
$newThemePublic->active = true;
$newThemePublic->save();
}
if ($activeThemeAdmin->id != Input::get('theme_admin')) {
$activeThemeAdmin->active = false;
$activeThemeAdmin->save();
$newThemeAdmin = Theme::find(Input::get('theme_public'));
$newThemeAdmin->active = true;
$newThemeAdmin->save();
}
//Delete Cache
Cache::forget('DB_ThemeByType');
//Options
$options = Option::all();
foreach ($options as $option) {
if ($option->key == "site_url") {
$option->value = Input::get('site_url');
}
if ($option->key == "cover_path") {
$option->value = Input::get('cover_path');
}
if ($option->key == "admin_email") {
$option->value = Input::get('admin_email');
}
if ($option->key == "analytics") {
$option->value = Input::get('analytics');
}
if ($option->key == "i18n_site_name") {
//Update translations
foreach ($site_name_locales as $locale) {
if (!I18n::find($option->value)->updateText($locale, Input::get('site_name_' . $locale))) {
return Redirect::to('admin/option')->with('error', Lang::get('admin.option_site_name_update_error'));
}
}
}
if ($option->key == "i18n_social_title") {
//Update translations
foreach ($social_title_locales as $locale) {
if (!I18n::find($option->value)->updateText($locale, Input::get('social_title_' . $locale))) {
return Redirect::to('admin/option')->with('error', Lang::get('admin.option_social_title_update_error'));
}
}
}
if ($option->key == "i18n_social_description") {
//Update translations
foreach ($social_description_locales as $locale) {
if (!I18n::find($option->value)->updateText($locale, Input::get('social_description_' . $locale))) {
return Redirect::to('admin/option')->with('error', Lang::get('admin.option_social_description_update_error'));
}
}
}
$option->save();
}
//.........这里部分代码省略.........
示例4: i18n
/**
* Additional method
*
* @var string
*/
public function i18n()
{
return I18n::find($this->i18n_title);
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$rules = array();
$tag_name_locales = array();
foreach (Input::all() as $k => $v) {
if (strpos($k, 'tag_name_') !== false) {
$rules[$k] = Config::get('validator.admin.option_site_name');
$tag_name_locales[] = mb_substr($k, strlen('tag_name_'), strlen($k) - strpos($k, 'tag_name_'));
}
}
// Validate the inputs
$validator = Validator::make(Input::all(), $rules);
$tag = Tag::find($id);
if ($validator->passes()) {
if (!empty($tag)) {
//Update translations
foreach ($tag_name_locales as $locale) {
if (!I18n::find($tag->i18n_name)->updateText($locale, Input::get('tag_name_' . $locale))) {
return Redirect::to('admin/tag')->with('error', Lang::get('admin.tag_update_error'));
}
}
//track user
parent::track('update', 'Tag', $tag->id);
return Redirect::to('admin/tag')->with('success', Lang::get('admin.tag_edit_success'));
}
// Redirect to the blog post create tag
return Redirect::to('admin/tag/' . $id . '/edit')->with('error', Lang::get('admin.tag_edit_fail'));
}
// Form validation failed
return Redirect::to('admin/tag/' . $id . '/edit')->withInput()->withErrors($validator);
}