1

PHPアプリケーションで奇妙な問題に直面してgettextいます。それは私の開発マシン(Ubuntu 10.10 32ビット、2 x Windows 7 64ビット、Windows 7 32ビット、すべてXAMPPを実行している)で動作します。

本番サーバーは、Linux64ビットのフレーバーを実行する有料ホストです。正確にはわかりません。私はそれが重要かどうかを調べることを試みることができます。

gettextを初期化する方法は次のとおりです。

//just FYI:
//$this->data['language'] == 'pl'
//dirname(__FILE__).'/../language/locale' ==
//'/home/mingos/public_html/example.com/application/controllers/../language/locale'

putenv('LANGUAGE='.$this->data['language']);
putenv('LANG='.$this->data['language']);
putenv('LC_ALL='.$this->data['language']);
setlocale(LC_ALL,$this->data['language']);

bindtextdomain($this->data['language'], dirname(__FILE__).'/../language/locale');
bind_textdomain_codeset($this->data['language'],'UTF-8');
textdomain($this->data['language']);

私はphpinfo()サーバー上で実行し、変更できない可能性を除いて、それgettextが有効でオフになっていることを発見しました(私は思います)。safe_modeLC_ALL

コンパイルされたgettextカタログは次のとおりです。

/home/mingos/public_html/example.com/application/language/locale/pl/LC_MESSAGES/pl.mo

したがって、で設定されたパスbindtextdomainは正しいです。

通知や警告は表示gettextされませんが、カタログから翻訳を抽出せず、フィードされた文字列を返すだけです。たとえば、の代わりにgettext('About us')returnsを返します。About usO nas

カタログ自体はを使用して正しくコンパイルさpoEditれ、4つの開発マシンで動作していることが確認されています。

これの他の考えられる原因は何でしょうか?

4

2 に答える 2

2

gettextは、インストールされたロケールのみをサポートします。ホスティングプロバイダーにシェルがある場合は、「locale -a」を実行して、インストールされているロケールのリストを表示する必要があります。ホスティングプロバイダーに連絡して、plに必要な言語パックをインストールしてもらう必要がある場合があります。

于 2011-03-11T01:27:12.287 に答える
1

An old question, but I wanted to explain why it worked on Windows and not on Linux. Windows servers don't use the same locale names as Linux servers. For example, in Windows you will have "en", but on Linux you'll have "en_EN". It's the same with Polish, on Windows it will be "pl" and on Linux it will be "pl_PL". You'll need to have some type of test for your local or live server and change the locale string accordingly.

于 2014-05-28T22:36:45.867 に答える