문제

On localhost, the languages Spanish, Russian, and Romanian languages display correctly, but when we moved our site to our production server on AWS, our text is not showing correctly.

We are using get text and .po files to display our languages. Text directly from our database display fine, only text from the .po files are broken.

Broken example: http://ru.artzoco.com/seller/102/YallooArt

How it is supposed to look: http://en.artzoco.com/seller/102/YallooArt

Our GetText Code:

//language sudomain process  http://stackoverflow.com/q/18996503/1744357
$host = explode(".",$_SERVER['HTTP_HOST']);
switch ($host[0]) {
  case 'en':
    $locale = 'en_US';
    break;
  case 'es':
    $locale = 'es_ES';
    break;
  case 'ru':
    $locale = 'ru_RU';
    break;
  case 'ro':
    $locale = 'ro_RO';
    break;
  default:
    $locale = 'en_US';
    break;
}
putenv("LANG=$locale"); 
$loc_es = setlocale(LC_ALL, $locale); 
bindtextdomain("translations", "../../locale/");  
textdomain("translations");
도움이 되었습니까?

해결책 2

I discovered for a linux server, I needed to call this line specifically for our code:

bind_textdomain_codeset("translations", "utf-8");

Since we were on a windows server on our localhost, it was working without this code line.

다른 팁

I see this in the php manual entry for gettext:

Note:

Setting a language isn't enough for some systems and the putenv() should be used to define the current locale.

It's possible there are differences between your local machine and production server defaults, so try setting the environment variable above to your desired language explicitly.

My next best guess is that it's a character encoding issue on your production server coming from the database (not sure if you're even using one).

Are you querying the data from a mysql data source? If so, try the mysql_set_charset function prior to your retrieval:

mysql_set_charset('utf8');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top