# Language 소개

* `Locale` 에 따른 언어를 출력할 수 있도록 지원하며, `getText`방식이 적용되어 있습니다.
* 커스터마이징 상점의 경우 언어 설정을 별도 수정하여 사용할 수 없습니다. (추후 지원 예정)

## 📌 **기본 Usage**

고도몰 컨트롤러 및 컴포넌트에서의 기본적인 사용법은 아래와 같으며 치환코드는 1개만 넣을 수 있습니다.

```php
__('오류가 발생하였습니다.');
__('%s 오류가 발생하였습니다.', $erroCode);
```

치환 문자를 사용해야 하는 경우,

```php
sprintf(__(%s), $sample1, $sample2);
```

## 📌 **상세 Usage**

아래 함수는 전역함수로 어느 파일에서도 사용할 수 있습니다.

* `$original` : 기본메시지를 선언합니다.
* `$plural` : 기본메시지의 복수형을 선언합니다.
* `$value` : 복수형 사용을 위한 조건으로 정수형 숫자를 선언합니다.
* `$context` : 메시지를 포함하는 위치 정보로 동일 단어를 다르게 사용할 수 있습니다.
* `$domain` : 도메인은 언어파일의 범위(영역)를 나타내며 고도몰에서는 파일 이름을 도메인으로 사용하고 있습니다.

### **기본형**

```php
__($original)
```

```
#: data/skin/front/food_story/main/index.html:281
msgid "테스트"
msgstr "test"
```

```php
echo __('테스트');
__e('테스트');

// print
test
test
```

### **복수형**

```php
n__($original, $plural, $value)
```

```cli
#: data/skin/front/food_story/main/index.html:281
msgid "테스트"
msgid_plural "테스트들"
msgstr[0] "test"
msgstr[1] "tests"
```

```php
echo n__('테스트', '테스트들', 1);
echo n__('테스트', '테스트들', 2);

// print
test
tests
```

### **컨텍스트형**

```php
p__($context, $original)
```

```cli
#: 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"
```

```php
echo p__('메뉴', '테스트');
echo p__('도구', '테스트');

// print
menu test
tool test
```

### **도메인형**

```php
d__($domain, $original)
```

```cli
// 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"
```

```php
echo d__('도메인1', '테스트');
echo d__('도메인2', '테스트');

// print
domain1 test
domain2 test
```

### **도메인 컨텍스트형**

```php
dp__($domain, $context, $original)
```

```cli
// 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"
```

```php
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
```

### **도메인 컨텍스트 복수형**

```php
dnp__($domain, $context, $original, $plural, $value)
```

```cli
// 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"
```

```php
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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devcenter-help.nhn-commerce.com/guide/preparation/detailed-structure/language.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
