Skip to content

Commit 09a5611

Browse files
i18n(ko-KR): update astro-i18n.mdx (#12676)
Co-authored-by: Yan <[email protected]>
1 parent 78a6f59 commit 09a5611

File tree

1 file changed

+118
-1
lines changed

1 file changed

+118
-1
lines changed

src/content/docs/ko/reference/modules/astro-i18n.mdx

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ i18n 라우터를 사용하여 프로젝트에 대한 경로를 생성하는 것
2828
## `astro:i18n`에서 가져오기
2929

3030
```js
31-
import {
31+
import {
3232
getRelativeLocaleUrl,
3333
getAbsoluteLocaleUrl,
3434
getRelativeLocaleUrlList,
@@ -40,6 +40,10 @@ import {
4040
notFound,
4141
middleware,
4242
requestHasLocale,
43+
normalizeTheLocale,
44+
pathHasLocale,
45+
toCodes,
46+
toPaths
4347
} from 'astro:i18n';
4448
```
4549

@@ -335,3 +339,116 @@ export const onRequest = defineMiddleware(async (context, next) => {
335339
return new Response("Not found", { status: 404 });
336340
})
337341
```
342+
343+
### `normalizeTheLocale()`
344+
345+
<p>
346+
347+
**타입:** `(locale: string) => string`
348+
</p>
349+
350+
주어진 로케일의 밑줄(`_`)을 하이픈(`-`)으로 바꾸고 소문자 버전으로 반환합니다.
351+
352+
```astro title="src/pages/index.astro"
353+
---
354+
import { normalizeTheLocale } from "astro:i18n";
355+
356+
normalizeTheLocale("it_VT") // `it-vt`를 반환합니다.
357+
// 현재 로케일이 `"pt-PT"`라고 가정할 때:
358+
normalizeTheLocale(Astro.currentLocale) // `pt-pt`를 반환합니다.
359+
---
360+
```
361+
362+
### `pathHasLocale()`
363+
364+
<p>
365+
366+
**타입:** `(path: string) => boolean`<br />
367+
<Since v="4.6.0" />
368+
</p>
369+
370+
주어진 경로에 구성된 로케일이 포함되어 있는지 확인합니다.
371+
372+
이것은 URL 경로의 로케일에 의존하는 i18n 유틸리티를 사용하기 전에 오류를 방지하는 데 유용합니다.
373+
374+
```js title="astro.config.mjs"
375+
export default defineConfig({
376+
i18n: {
377+
locales: [
378+
{ codes: ["it-VT", "it"], path: "italiano" },
379+
"es"
380+
]
381+
}
382+
})
383+
```
384+
385+
```astro title="src/pages/index.astro"
386+
---
387+
import { pathHasLocale } from "astro:i18n";
388+
389+
pathHasLocale("italiano"); // `true`를 반환합니다.
390+
pathHasLocale("es"); // `true`를 반환합니다.
391+
pathHasLocale('/es/blog/'); // `true`를 반환합니다.
392+
pathHasLocale("it-VT"); // `false`를 반환합니다.
393+
---
394+
```
395+
396+
### `toCodes()`
397+
398+
<p>
399+
400+
**타입:** `(locales: Locales) => string[]`<br />
401+
<Since v="4.0.0" />
402+
</p>
403+
404+
구성에서 정의된 각 로케일에 대해 구성된 로케일 코드를 검색합니다. 로케일에 여러 코드가 연결된 경우에는 배열에 첫 번째 코드만 추가됩니다.
405+
406+
```js title="astro.config.mjs"
407+
export default defineConfig({
408+
i18n: {
409+
locales: [
410+
{ codes: ["it-VT", "it"], path: "italiano" },
411+
"es"
412+
]
413+
}
414+
})
415+
```
416+
417+
```astro title="src/pages/index.astro"
418+
---
419+
import { i18n } from "astro:config/client";
420+
import { toCodes } from "astro:i18n";
421+
422+
toCodes(i18n!.locales); // ["it-VT", "es"]
423+
---
424+
```
425+
426+
### `toPaths()`
427+
428+
<p>
429+
430+
**타입:** `(locales: Locales) => string[]`<br />
431+
<Since v="4.0.0" />
432+
</p>
433+
434+
구성에서 정의된 각 로케일에 대해 구성된 로케일 경로를 검색합니다.
435+
436+
```js title="astro.config.mjs"
437+
export default defineConfig({
438+
i18n: {
439+
locales: [
440+
{ codes: ["it-VT", "it"], path: "italiano" },
441+
"es"
442+
]
443+
}
444+
})
445+
```
446+
447+
```astro title="src/pages/index.astro"
448+
---
449+
import { i18n } from "astro:config/client";
450+
import { toPaths } from "astro:i18n";
451+
452+
toPaths(i18n!.locales); // ["italiano", "es"]
453+
---
454+
```

0 commit comments

Comments
 (0)