2

I am running Qtranslate for my website see: http://www.businessinstitute.nl/

I am very impressed by this plugin. Now my only problem is that I cannot set a custom title and description for my homepage per language. I can only setup one line for the title in the general settings for my website.

I have installed Qtranslate META where I can set a custom title and description per page, but my only problem is the homepage.

4

1 に答える 1

1

質問で PHP にタグを付けたので、「問題」に対処するための純粋な PHP の方法を次に示します。

  1. Web サイトの「タイトル」のすべての異なる翻訳の配列で静的宣言を行うことができます。
  2. ユーザーのブラウザが accept_language を送信しているかどうかを確認します
  3. 特定のタイトルが配列に存在する場合、そのユーザーの言語で特定のタイトルを表示します
  4. 存在しない場合は、デフォルトの言語を提示してください...

サードパーティのソフトウェア/プラグインに依存しない簡単な実装を次に示します。

 $website_titles = array ('en' => 'my cool website', 
                          'fr' => 'mon site cool',
                          'zn' => '我的酷网站');
 if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && isset($website_titles[$_SERVER['HTTP_ACCEPT_LANGUAGE']])) {
     echo '<title>' . $website_titles[$_SERVER['HTTP_ACCEPT_LANGUAGE']] . '</title>';
 } else { 
     // print default title
     echo '<title>my cool website</title>';
 }
于 2011-06-24T10:36:47.563 に答える