Laravel本地化为德语和特殊字母 [英] Laravel localization to German and special letters
问题描述
我在Laravel应用程序中遇到一些德语的特殊字母(ö,ü...)的问题.
I have a problem with some German's special letters (ö, ü...) in my Laravel application.
我的编码设置为UTF-8.
My encoding is set to UTF-8.
一切都可以与数据库中的内容(utf8_general_ci
)一起正常工作.当我将一些文本硬编码到Blade视图文件中时,也很好.但是,我正在使用带有关联数组的本地化文件(/app/lang/de/myFile.php
).
Everything works fine with the content from the database (where is utf8_general_ci
). When I hardcode some text to Blade view files, that's fine, too. But, I'm using localization files (/app/lang/de/myFile.php
) with an associative array.
该数组中的德语字符显示为``.奇怪的是,当我在Blade中使用var_dump(trans('myFile.key'))
时,特殊字符有效,但是当使用echo trans('myFile.key')
时,会出现问号.
German characters from that array are displayed as � � �. What is strange, when I var_dump(trans('myFile.key'))
in Blade, special characters works, but when echo trans('myFile.key')
, there are that question marks.
有什么想法吗?
推荐答案
好吧,几个小时后:)我成功了!关键是要以UTF-8编码保存本地化文件.默认情况下,崇高文本"将其另存为Windows-1250.
Ok, after few hours :) I succeed! The point is to save localization file in UTF-8 encoding. Sublime Text by default saved it as Windows-1250.
这篇关于Laravel本地化为德语和特殊字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!