laravel5 switch Chinese language
This article mainly introduces the switching of Chinese language in laravel5. It has certain reference value. Now I share it with you. Friends in need can refer to it
Laravel-lang
Laravel 5 Language pack, including 52 languages, based on caouecs/Laravel-lang.
Installation
composer require "overtrue/laravel-lang:~3.0"
Laraval 5.*
After completing the above operation, copy the project file ## Replace the next line <div class="code" style="position:relative; padding:0px; margin:0px;"><pre style="font-family:'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size:13.6px;margin-bottom:0px;padding-top:16px;padding-bottom:16px;line-height:1.45;background-color:rgb(246,248,250);" class="brush:php;toolbar:false;">Illuminate\Translation\TranslationServiceProvider::class,</pre><div class="contentsignin">Copy after login</div></div>
in #config/app.php
Overtrue\LaravelLang\TranslationServiceProvider::class,
bootstrap/app.php Add the following line:
$app->register(Overtrue\LaravelLang\TranslationServiceProvider::class);
config/app.php:
'locale' => 'zh-CN',
.env file:
APP_LOCALE=zh-CN
使用
和正常使用一样,你如果需要额外添加语言项,请在 resources/lang/zh-CN/
下建立你自己的文件即可,也可以建立同样的文件来替换掉默认的语言部分。
添加自定义语言项
例如创建文件 resources/lang/zh-CN/demo.php
:
<?php return [ 'user_not_exists' => '用户不存在', 'email_has_registed' => '邮箱 :email 已经注册过!',];
然后在任何地方:
echo trans('demo.user_not_exists'); // 用户不存在 echo trans('demo.email_has_registed', ['email' => 'anzhengchao@gmail.com']);// 邮箱 anzhengchao@gmail.com 已经注册过!
替换掉默认的语言项
我们假设想替换掉密码重围成功的提示文字为例,创建 resources/lang/zh-CN/passwords.php
:
<?php return [ 'reset' => '您的密码已经重置成功了,你可以使用新的密码登录了!',];
只放置你需要替换的部分即可。
将翻译文件拷贝到你的项目 resources/lang/
目录下:
$ php artisan lang:publish [LOCALES] {--force}
examples:
$ php artisan lang:publish zh-CN,zh-HK,th,tk
以上就是本篇文章的全部内容了,更多相关内容请关注PHP中文网。
The above is the detailed content of laravel5 switch Chinese language. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Work on the same setup for too long or share your PC with others. You may have some language packs installed, which often create conflicts. So, it’s time to remove unwanted display languages in Windows 11. Speaking of conflicts, when there are multiple language packs, inadvertently pressing Ctrl+Shift changes the keyboard layout. If not taken care of, this can be a hindrance to the task at hand. So, let’s jump right into the method! How to remove display language from Windows 11? 1. From Settings press + to open the Settings app, go to Time & Language from the navigation pane and click on Language & Region. WindowsI click the ellipsis next to the display language you want to remove and select Remove from the pop-up menu. Click "

It's no secret that the iPhone is one of the most user-friendly electronic gadgets, and one of the reasons why is that it can be easily personalized to your liking. In Personalization, you can change the language to a different language than the one you selected when setting up your iPhone. If you're familiar with multiple languages, or your iPhone's language setting is wrong, you can change it as we explain below. How to Change the Language of iPhone [3 Methods] iOS allows users to freely switch the preferred language on iPhone to adapt to different needs. You can change the language of interaction with Siri to facilitate communication with the voice assistant. At the same time, when using the local keyboard, you can easily switch between multiple languages to improve input efficiency.

Xiaomi 14Ultra is one of the most popular Xiaomi models this year. Xiaomi 14Ultra not only upgrades the processor and various configurations, but also brings many new functional applications to users. This can be seen from the sales of Xiaomi 14Ultra mobile phones. It is very popular, but there are some commonly used functions that you may not know yet. So how does Xiaomi 14Ultra switch between 4g and 5g? Let me introduce the specific content to you below! How to switch between 4g and 5g on Xiaomi 14Ultra? 1. Open the settings menu of your phone. 2. Find and select the "Network" and "Mobile Network" options in the settings menu. 3. In the mobile network settings, you will see the "Preferred network type" option. 4. Click or select this option and you will see

How to convert Win11 Home Edition to Win11 Professional Edition? In Win11 system, it is divided into Home Edition, Professional Edition, Enterprise Edition, etc., and most Win11 notebooks are pre-installed with Win11 Home Edition system. Today, the editor will show you the steps to switch from win11 home version to professional version! 1. First, right-click on this computer on the win11 desktop and properties. 2. Click Change Product Key or Upgrade Windows. 3. Then click Change Product Key after entering. 4. Enter the activation key: 8G7XN-V7YWC-W8RPC-V73KB-YWRDB and select Next. 5. Then it will prompt success, so you can upgrade win11 home version to win11 professional version.

Many friends may not be used to the win system when they first come into contact with it. There are dual systems in the computer. At this time, you can actually switch between the two systems. Let's take a look at the detailed steps for switching between the two systems. How to switch between two systems in win10 system 1. Shortcut key switching 1. Press the "win" + "R" keys to open Run 2. Enter "msconfig" in the run box and click "OK" 3. In the open "System Configuration" In the interface, select the system you need and click "Set as Default". After completion, "Restart" can complete the switch. Method 2. Select switch when booting 1. When you have dual systems, a selection operation interface will appear when booting. You can use the keyboard " Up and down keys to select the system

How to switch between Apple dual systems when starting up Apple computers are powerful devices. In addition to their own macOS operating system, you can also choose to install other operating systems, such as Windows, to achieve dual system switching. So how do we switch between the two systems when booting? This article will introduce to you how to switch between dual systems on Apple computers. First of all, before installing dual systems, we need to confirm whether our Apple computer supports dual system switching. Generally speaking, Apple computers are based on

Sometimes we just install the computer system and find that the system is in English. In this case, we need to change the computer language to Chinese. So how to change the computer language to Chinese in the win10 system? Now Give you specific operation methods. How to change the computer language in win10 to Chinese 1. Turn on the computer and click the start button in the lower left corner. 2. Click the settings option on the left. 3. Select "Time and Language" on the page that opens. 4. After opening, click "Language" on the left. 5. Here you can set the computer language you want.

Win11 supports users to use the alt+tab shortcut key to bring up the desktop switching tool, but recently a friend encountered the problem that win11 alt+tab cannot switch the interface. I don’t know the reason or how to solve it. Why can't win11 alt+tab switch the interface? Answer: Because the shortcut key function is disabled, here is the solution: 1. First, we press "win+r" on the keyboard to open the run. 2. Then enter "regedit" and press Enter to open the group policy. 3. Then enter "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer"
