Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在php8.1下,thinkphp8.0多语言不能正常使用 #1142

Open
tuweifu opened this issue Nov 15, 2023 · 1 comment
Open

在php8.1下,thinkphp8.0多语言不能正常使用 #1142

tuweifu opened this issue Nov 15, 2023 · 1 comment

Comments

@tuweifu
Copy link

tuweifu commented Nov 15, 2023

PHP环境:PHP Version 8.1.7
框架版本:ThinkPHP 8.0
出现的异常:
1、多应用模式下,在全局配置中开启多语言,在全局中间件文件中添加了语言包的中间件定义。然后在页面传入lang=en测试发现多语言切换无效。检查cookie发现cookie值已写入 en-us,但是使用lang输出的还是中文。检查多次语言包你让和lang.php配置都正常。
2、然后我尝试将中间件中的语言包定义,移到单个应用中的中间件文件中定义。发现又正常了。然后我尝试将全局配置lang.php放到多应用的应用中配置中。发现应用配置的lang.php不会生效。语言包的cookie名称等还是使用全局文件的。
3、后面找到一篇类似问题的反馈:https://blog.csdn.net/qq_24118445/article/details/132461009 ,于是我尝试将
\vendor\topthink\framework\src\think\App.php 中的 $this->loadLangPack(); 注释,再返回测试。发现一切都正常了。多应用中应用配置生效了,语言包也正常切换了。

@tuweifu
Copy link
Author

tuweifu commented Nov 15, 2023

我用的是多应用模式,不懂是我的配置问题,还是什么问题,弄了很久,最后实在没办法,把 \vendor\topthink\framework\src\think\App.php 中的 $this->loadLangPack(); 注释了,就都正常了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant