问题
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