Laravel 将例外消息语言从法语更改为英语

Laravel change exceptions message language from French to English

我最近使用 composer 下载了 Laravel 5.4.*,我注意到默认的异常消息以法语显示,如何将其更改为英语?

请参阅下面屏幕截图中突出显示的文字

在您的 .env 文件中更改这些值

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_LOCALE_PHP=en_US

还要确保清除您的配置

        composer dumpautoload -o
        php artisan optimize
        php artisan clear-compiled
        php artisan cache:clear
        php artisan route:clear
        php artisan view:clear
        php artisan config:clear

运行这些命令

希望对您有所帮助

这实际上是一个 PostgreSQL 配置问题。

检查您的 postgresql.conf 文件的区域设置,如果您将它们设置为英语,您将得到您想要的:

lc_messages = 'English_United States.1252'                  # locale for system error message strings
lc_monetary = 'English_United States.1252'                  # locale for monetary formatting
lc_numeric = 'English_United States.1252'                   # locale for number formatting
lc_time = 'English_United States.1252'                      # locale for time formatting

这里有关于 locale settings in PosgreSQL 的更多信息。

实际字符串取决于您的系统:

What locales are available on your system under what names depends on what was provided by the operating system vendor and what was installed. On most Unix systems, the command locale -a will provide a list of available locales. Windows uses more verbose locale names, such as German_Germany or Swedish_Sweden.1252, but the principles are the same.

所以对于 Windows 它是 English_United States 而 *unix 通常是 en_US.

起初我以为这个语言问题与Laravel有关,后来意识到这也存在于其他PHP CMS和框架中,所以想到在这里更新。

我通过修改 MySQL 设置文件解决了这个问题(即:C:\wamp\bin\mysql\mysql*\my.ini)

已更改

# Change your locale here !
lc-messages=fr_FR

# Change your locale here !
lc-messages=en_US

如果需要,请重新启动您的 wamp 服务器。

您还可以通过执行以下查询来设置 MySQL 会话。 Click for more

SET lc_messages = 'en_US';

谢谢大家的帮助。