Symfony2 translations and locale with not ASCII symbols

六月ゝ 毕业季﹏ 提交于 2019-12-12 06:47:51

问题


We are trying to add 'russian' locale to Symfony2 application. But the translation service does not bring up cyrillic characters correctly.

messages.ru.xliff saved with UTF-8 encoding contains:

<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="en" datatype="plaintext" original="file.ext">
        <body>
            <trans-unit id="1">
                <source>Hello</source>
                <target>Привет</target>
            </trans-unit>
        </body>
    </file>
</xliff>

but

echo $this->get('translator')->trans('Hello').'<br>';

dumps something like 'РџСЂРёРІС–С‚' instead of 'Привет'. However ASCII symbols form messages.xx.xliff are fetched well.


回答1:


Specifying UTF-8 charset in html does the job

<meta http-equiv="content-type" content="text/html; charset=UTF-8">


来源:https://stackoverflow.com/questions/20130580/symfony2-translations-and-locale-with-not-ascii-symbols

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!