HTML
Lingo.dev CLI를 사용한 HTML 파일의 AI 번역
HTML이란 무엇인가요?
HTML(HyperText Markup Language)은 웹 페이지와 웹 애플리케이션을 만들기 위한 표준 마크업 언어입니다. 태그를 사용하여 콘텐츠를 구조화하고 제목, 단락, 링크, 이미지, 양식과 같은 요소를 정의합니다.
Lingo.dev CLI란 무엇인가요?
Lingo.dev CLI는 AI를 사용하여 앱과 콘텐츠를 번역하기 위한 무료 오픈소스 CLI입니다. 기존 파이프라인과 통합하면서 전통적인 번역 관리 소프트웨어를 대체하도록 설계되었습니다.
자세한 내용은 개요를 참조하세요.
이 가이드에 대하여
이 가이드는 Lingo.dev CLI를 사용하여 HTML 파일을 번역하는 방법을 설명합니다.
다음 내용을 배우게 됩니다:
- 처음부터 프로젝트 생성하기
- 번역 파이프라인 구성하기
- AI로 번역 생성하기
사전 요구사항
Lingo.dev CLI를 사용하려면 Node.js v18 이상이 설치되어 있어야 합니다:
❯ node -v
v22.17.0
1단계. 프로젝트 설정하기
프로젝트 디렉토리에 i18n.json 파일을 생성합니다:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
이 파일은 번역할 언어와 파일 시스템에서 지역화 가능한 콘텐츠가 존재하는 위치를 포함하여 번역 파이프라인의 동작을 정의합니다.
사용 가능한 속성에 대해 자세히 알아보려면 i18n.json을 참조하세요.
2단계. 소스 로케일 구성하기
_소스 로케일_은 콘텐츠가 원래 작성된 언어와 지역입니다. 소스 로케일을 구성하려면 i18n.json 파일에서 locale.source 속성을 설정하세요:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
소스 로케일은 BCP 47 언어 태그로 제공되어야 합니다.
Lingo.dev CLI가 지원하는 로케일 코드의 전체 목록은 지원되는 로케일 코드를 참조하세요.
3단계. 대상 로케일 구성하기
_대상 로케일_은 콘텐츠를 번역하고자 하는 언어와 지역입니다. 대상 로케일을 구성하려면 i18n.json 파일에서 locale.targets 속성을 설정하세요:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
4단계. 소스 콘텐츠 생성하기
아직 생성하지 않았다면, 번역할 콘텐츠가 포함된 하나 이상의 HTML 파일을 생성하세요. 이 파일들은 경로 어딘가에 소스 로케일이 포함된 위치에 있어야 합니다(예: en/과 같은 디렉토리 이름이나 messages.en.html과 같은 파일 이름의 일부로).
HTML 파일의 경우, 번역 가능한 콘텐츠는 다음과 같습니다:
- HTML 요소 내의 텍스트 콘텐츠
- 다음을 포함한 속성 값:
alt속성(이미지 설명)title속성(툴팁)placeholder속성(입력 힌트)value속성(버튼 및 입력 값)- 메타 태그
content속성
lang속성은 대상 로케일과 일치하도록 자동으로 업데이트됩니다
스크립트 태그, 스타일 태그 및 번역 불가능한 속성은 보존됩니다.
예시:
<!DOCTYPE html>
<html lang="en">
<head>
<title>MyApp - Hello World</title>
<meta name="description" content="A simple demo app" />
</head>
<body>
<h1>Welcome to MyApp</h1>
<p>Hello, world! This is a simple demo with <strong>bold text</strong>.</p>
<img src="example.jpg" alt="Example image" />
</body>
</html>
5단계. 버킷 생성하기
-
i18n.json파일에서buckets객체에"html"객체를 추가하세요:{ "$schema": "https://lingo.dev/schema/i18n.json", "version": "1.10", "locale": { "source": "en", "targets": ["es"] }, "buckets": { "html": {} } } -
"html"객체에서 하나 이상의include패턴 배열을 정의하세요:{ "$schema": "https://lingo.dev/schema/i18n.json", "version": "1.10", "locale": { "source": "en", "targets": ["es"] }, "buckets": { "html": { "include": ["./[locale]/example.html"] } } }이러한 패턴은 번역할 파일을 정의합니다.
패턴 자체는:
- 구성된 로케일의 플레이스홀더로
[locale]을 포함해야 합니다 - 파일 경로를 가리킬 수 있습니다(예:
"[locale]/config.html") - 와일드카드 플레이스홀더로 별표를 사용할 수 있습니다(예:
"[locale]/*.html")
재귀적 글로브 패턴(예:
**/*.html)은 지원되지 않습니다. - 구성된 로케일의 플레이스홀더로
6단계. LLM 구성하기
Lingo.dev CLI는 AI로 콘텐츠를 번역하기 위해 대규모 언어 모델(LLM)을 사용합니다. 이러한 모델 중 하나를 사용하려면 지원되는 제공업체의 API 키가 필요합니다.
가능한 빨리 시작하려면 월 10,000 토큰의 무료 사용량을 제공하는 자체 호스팅 플랫폼인 Lingo.dev Engine을 사용하는 것이 좋습니다:
-
다음 명령어를 실행하세요:
npx lingo.dev@latest login이렇게 하면 기본 브라우저가 열리고 인증을 요청합니다.
-
안내에 따라 진행하세요.
7단계. 번역 생성하기
i18n.json 파일이 포함된 디렉토리에서 다음 명령어를 실행하세요:
npx lingo.dev@latest run
이 명령어는 다음을 수행합니다:
i18n.json파일을 읽습니다.- 번역이 필요한 파일을 찾습니다.
- 파일에서 번역 가능한 콘텐츠를 추출합니다.
- 구성된 LLM을 사용하여 추출된 콘텐츠를 번역합니다.
- 번역된 콘텐츠를 파일 시스템에 다시 작성합니다.
번역이 처음 생성될 때 i18n.lock 파일이 생성됩니다. 이 파일은 어떤 콘텐츠가 번역되었는지 추적하여 이후 실행 시 불필요한 재번역을 방지합니다.
예시
en/example.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>MyApp - Hello World</title>
<meta name="description" content="A simple demo app" />
</head>
<body>
<h1>Welcome to MyApp</h1>
<p>Hello, world! This is a simple demo with <strong>bold text</strong>.</p>
<img src="example.jpg" alt="Example image" />
<input type="text" placeholder="Enter text here" />
<a href="#" title="Click for more">Learn more</a>
</body>
</html>
es/example.html
<!DOCTYPE html>
<html lang="es">
<head>
<title>MyApp - Hola Mundo</title>
<meta name="description" content="Una aplicación de demostración simple" />
</head>
<body>
<h1>Bienvenido a MyApp</h1>
<p>¡Hola, mundo! Esta es una demostración simple con <strong>texto en negrita</strong>.</p>
<img src="example.jpg" alt="Imagen de ejemplo" />
<input type="text" placeholder="Ingresa texto aquí" />
<a href="#" title="Haz clic para más">Saber más</a>
</body>
</html>
i18n.json
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {
"html": {
"include": ["./[locale]/example.html"]
}
}
}
i18n.lock
version: 1
checksums:
ab95e8c959a889717f02a05af5c5b1e6:
head/0/0: 7d39787547365ee4194f29f3f54e5c05
head/1#content: 49f8864eb0e53903f04532bf33e1e4fa
head/2#content: c2a1da93efb7e744d100df705e5fcbfd
head/3#content: d94b318cb327f61f1aea44a6cb1fdcad
body/0/0: d1c3a9f35e377554a4ccaa467ca26614
body/1/0: e19afd1952881bdf10063f9478980147
body/1/1/0: 7cd9256312384858ecba6c29d3c2e550
body/1/2: ce8b9bb44f031705708a70e068bb73c8
body/1/3/0: 037d114f19b882f08994712b8d9c1e37
body/1/4: f05f450fffcb17520c441ab9789f40ce
body/2/0/0/0: 57d373bcffe2d376cbf9919da30ca30b
body/3#alt: 68f95fca639f8bf72a4796b6734b02d5
body/4#alt: cb7d920c3bbcade1c8e0307093f58573
body/5#placeholder: a05ce3b4578f55e41bd2ad4964f966b4
body/6#placeholder: a4554ed67c02872e302b0042724f859d
body/7#title: c903c6985a40ce02d65c90229de35a4e
body/7/0: e598091d132f890c37a6d4ed94f6d794
body/8#title: d656021ba5f485fa1a82f8aac6ecc5de
body/8/0: 1c6856488bd34ad87fcacce2d8e66a0b
body/9/0: 862964e6cd73cdffdcac622406c6bac9