고도몰 튜닝 가이드 준비하기 심화 구조 이해 Language 소개 고도몰의 Language 를 소개하는 내용입니다.
Locale
에 따른 언어를 출력할 수 있도록 지원하며, getText
방식이 적용되어 있습니다.
튜닝상점의 경우 언어 설정을 별도 수정하여 사용할 수 없습니다. (추후 지원 예정)
📌 기본 Usage
고도몰 컨트롤러 및 컴포넌트에서의 기본적인 사용법은 아래와 같으며 치환코드는 1개만 넣을 수 있습니다.
Copy __('오류가 발생하였습니다.');
__('%s 오류가 발생하였습니다.', $erroCode);
치환 문자를 사용해야 하는 경우,
Copy sprintf(__(%s), $sample1, $sample2);
📌 상세 Usage
아래 함수는 전역함수로 어느 파일에서도 사용할 수 있습니다.
$original
: 기본메시지를 선언합니다.
$plural
: 기본메시지의 복수형을 선언합니다.
$value
: 복수형 사용을 위한 조건으로 정수형 숫자를 선언합니다.
$context
: 메시지를 포함하는 위치 정보로 동일 단어를 다르게 사용할 수 있습니다.
$domain
: 도메인은 언어파일의 범위(영역)를 나타내며 고도몰에서는 파일 이름을 도메인으로 사용하고 있습니다.
기본형
Copy #: data/skin/front/food_story/main/index.html:281
msgid "테스트"
msgstr "test"
Copy echo __('테스트');
__e('테스트');
// print
test
test
복수형
Copy n__($original, $plural, $value)
Copy #: data/skin/front/food_story/main/index.html:281
msgid "테스트"
msgid_plural "테스트들"
msgstr[0] "test"
msgstr[1] "tests"
Copy echo n__('테스트', '테스트들', 1);
echo n__('테스트', '테스트들', 2);
// print
test
tests
컨텍스트형
Copy p__($context, $original)
Copy #: data/skin/front/food_story/main/index.html:281
msgctxt "메뉴"
msgid "테스트"
msgstr "menu test"
#: data/skin/front/food_story/main/index.html:281
msgctxt "도구"
msgid "테스트"
msgstr "tool test"
Copy echo p__('메뉴', '테스트');
echo p__('도구', '테스트');
// print
menu test
tool test
도메인형
Copy d__($domain, $original)
Copy // domain1 파일
#: data/skin/front/food_story/main/index.html:281
msgid "테스트"
msgstr "domain1 test"
// domain2 파일
#: data/skin/front/food_story/main/index.html:281
msgid "테스트"
msgstr "domain2 test"
Copy echo d__('도메인1', '테스트');
echo d__('도메인2', '테스트');
// print
domain1 test
domain2 test
도메인 컨텍스트형
Copy dp__($domain, $context, $original)
Copy // domain1 파일
#: data/skin/front/food_story/main/index.html:281
msgctxt "메뉴"
msgid "테스트"
msgstr "domain1 test"
// domain2 파일
#: data/skin/front/food_story/main/index.html:281
msgctxt "도구"
msgid "테스트"
msgstr "domain2 test"
Copy echo dp__('도메인1', '메뉴', '테스트');
echo dp__('도메인1', '도구', '테스트');
echo dp__('도메인2', '메뉴', '테스트');
echo dp__('도메인2', '도구', '테스트');
// print
domain1 menu test
domain1 tool test
domain2 menu test
domain2 tool test
도메인 컨텍스트 복수형
Copy dnp__($domain, $context, $original, $plural, $value)
Copy // domain1 파일
#: data/skin/front/food_story/main/index.html:281
msgctxt "메뉴"
msgid "테스트"
msgid_plural "테스트들"
msgstr[0] "domain1 test"
msgstr[1] "domain1 tests"
// domain2 파일
#: data/skin/front/food_story/main/index.html:281
msgctxt "도구"
msgid "테스트"
msgid_plural "테스트들"
msgstr[0] "domain2 test"
msgstr[1] "domain2 tests"
Copy echo dnp__('도메인1', '메뉴', '테스트', '테스트들', 1);
echo dnp__('도메인1', '도구', '테스트', '테스트들', 2);
echo dnp__('도메인1', '메뉴', '테스트', '테스트들', 1);
echo dnp__('도메인1', '도구', '테스트', '테스트들', 2);
// print
domain1 test
domain1 tests
domain2 test
domain2 tests
Last updated 9 months ago