2017-10-06 6 views
0

新しい多言語ウェブサイトを作成しようとしています。私はpoEDitgetText()関数を使用します。私はこのコードで私が逃したものは分かりません:多言語ウェブサイトpoEDitとgetText()

<?php 
    if (!function_exists("gettext")) 
    { 
     echo "gettext is not installed\n"; 
    } else { 
     echo "gettext is supported\n"; 
    } 

    $language = 'ar_JO'; 
    putenv("LANG=$language"); 
    setlocale(LC_ALL, $language); 

    $domain = 'ar_JO'; 
    bindtextdomain($domain, "./locale"); 
    bind_textdomain_codeset($domain, 'UTF-8'); 
    textdomain($domain); 

    echo _("HELLO_WORLD"); 
    echo _("hi this to be translated "); 

答えて

0

このディレクトリは非常にインポートされています。私はこの ":\ WAMP \ WWW \ loginSystemOOP /ロケール/ ar_JO/LC_MESSAGES/messages_ar_JO.mo C" を持っている

<?php 

$locale = 'de_DE'; 
//$locale = 'fr_CH'; 
$domain = 'messages'; 
$codeset = 'UTF-8'; 
$directory = __DIR__ . '/locale'; 

// Activate the locale settings 
putenv('LC_ALL=' . $locale); 
setlocale(LC_ALL, $locale); 

// Debugging output 
$file = sprintf('%s/%s/LC_MESSAGES/%s_%s.mo', $directory, $locale, $domain, $locale); 
echo $file . "\n"; 

// Generate new text domain 
$textDomain = sprintf('%s_%s', $domain, $locale); 

// Set base directory for all locales 
bindtextdomain($textDomain, $directory); 

// Set domain codeset (optional) 
bind_textdomain_codeset($textDomain, $codeset); 

// File: ./locale/de_DE/LC_MESSAGES/messages_de_DE.mo 
textdomain($textDomain); 

// test translations 
echo _('Yes'); 
+0

:このサンプルコードを試してみてくださいそして、

locale/de_DE/LC_MESSAGES/messages_de_DE.mo locale/de_DE/LC_MESSAGES/messages_de_DE.po 

:このようなディレクトリ構造を作成します。 と私のファイル構造は 'C:\ wamp \ www \ loginSystemOOP/locale/ar_JO/LC_MESSAGES /'です。 –