0
내 웹 사이트의 PHP 다국어 기능을 처리하는 방법에 대해 어떻게 생각하는지 알고 싶습니다.상수를 사용하여 PHP 다중 언어 웹 사이트 관리
먼저 언어가 포함 된 변수 $config['UserLang']
을 복구합니다. 사용자가 연결되어 있고 언어를 지정한 경우 $ _SESSION 또는 데이터베이스에서 복구합니다. 예를 들어, 내가 사용 가능한 언어 많은 파일이 디렉토리 include/langs
에서
require_once ('include/langs/'.$config['UserLang'].'.inc.php');
: 다음
$config['UserLang'] = 'fr';
나는 언어의 정수를 포함한 파일을 열 en.inc.php
, fr.inc.php
및 es.inc.php
예를 들어 en.inc.php
의 콘텐츠는 다음과 같습니다.
define("LANG_HOME_home", "Home");
define("LANG_HOME_contact", "Contact us");
define("LANG_HOME_phone", "Our phone");
define("LANG_HOME_address", "Our address");
define("LANG_HOME_desc", "Some description of the company <br> Another line about the company");
내가 DOM을 표시 할 때
그리고, : 그것은 잘 BU를 일하고
echo '
<div class="pad-t-20 txt-c">
'.LANG_HOME_desc.'
</div>';
아무것도 내가 그것을 개선하기 위해 할 수 있는가? 더 일반적인 방법이 있습니까?
감사합니다.
이 (작은 국제화 수준)를 볼 수 있습니다 https://github.com/Philipp15b/php-i18n – Jeff
예, 이것 좀 봐해야 scipt –