Xcode .strings 파일

Lingo.dev CLI를 사용한 Xcode .strings 파일의 AI 번역

Xcode .strings 파일이란?

Xcode .strings 파일은 iOS 및 macOS 애플리케이션에서 현지화된 텍스트를 저장하기 위한 Apple의 형식입니다. 주석과 특수 문자를 지원하는 간단한 키-값 형식을 사용합니다.

예시:

/* Basic examples */
"welcome_message" = "Hello, world!";
"login_button" = "Log In";
"error_message" = "Something went wrong";

/* Escaped characters */
"quote_example" = "She said \"Hello world!\"";
"newline_example" = "First line\nSecond line";

/* Unicode and special characters */
"unicode_example" = "Hello 世界 🌍";
"emoji" = "👋 Hello! 🎉";

Lingo.dev CLI란?

Lingo.dev CLI는 AI를 사용하여 앱과 콘텐츠를 번역하는 무료 오픈 소스 CLI입니다. 기존 파이프라인과 통합하면서 기존 번역 관리 소프트웨어를 대체하도록 설계되었습니다.

자세한 내용은 개요를 참조하세요.

이 가이드에 대하여

이 가이드는 Lingo.dev CLI를 사용하여 Xcode .strings 파일을 번역하는 방법을 설명합니다.

다음 내용을 배우게 됩니다:

  • 처음부터 프로젝트 생성하기
  • 번역 파이프라인 구성하기
  • 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단계. 소스 콘텐츠 생성

아직 생성하지 않았다면, 번역할 콘텐츠가 포함된 하나 이상의 Xcode .strings 파일을 생성하세요. 이러한 파일은 경로 어딘가에 소스 로케일이 포함된 위치에 있어야 합니다(예: en/와 같은 디렉토리 이름 또는 messages.en.strings와 같은 파일 이름의 일부).

5단계. 버킷 생성

  1. i18n.json 파일에서 buckets 객체에 "xcode-strings" 객체를 추가하세요:

    {
      "$schema": "https://lingo.dev/schema/i18n.json",
      "version": "1.10",
      "locale": {
        "source": "en",
        "targets": ["es"]
      },
      "buckets": {
        "xcode-strings": {}
      }
    }
    
  2. "xcode-strings" 객체에서 하나 이상의 include 패턴 배열을 정의하세요:

    {
      "$schema": "https://lingo.dev/schema/i18n.json",
      "version": "1.10",
      "locale": {
        "source": "en",
        "targets": ["es"]
      },
      "buckets": {
        "xcode-strings": {
          "include": ["./[locale]/example.strings"]
        }
      }
    }
    

    이러한 패턴은 번역할 파일을 정의합니다.

    패턴 자체는:

    • 구성된 로케일의 플레이스홀더로 [locale]를 포함해야 합니다
    • 파일 경로를 가리킬 수 있습니다(예: "[locale]/Localizable.strings")
    • 와일드카드 플레이스홀더로 별표를 사용할 수 있습니다(예: "[locale]/*.strings")

    재귀 glob 패턴(예: **/*.strings)은 지원되지 않습니다.

6단계. LLM 구성

Lingo.dev CLI는 대규모 언어 모델(LLM)을 사용하여 AI로 콘텐츠를 번역합니다. 이러한 모델 중 하나를 사용하려면 지원되는 제공업체의 API 키가 필요합니다.

가능한 한 빠르게 시작하려면 매월 10,000 토큰의 무료 사용량을 제공하는 자체 호스팅 플랫폼인 Lingo.dev Engine 사용을 권장합니다:

  1. Lingo.dev 계정에 가입하세요.

  2. 다음 명령을 실행하세요:

    npx lingo.dev@latest login
    

    기본 브라우저가 열리고 인증을 요청합니다.

  3. 안내에 따라 진행하세요.

7단계. 번역 생성하기

i18n.json 파일이 있는 디렉토리에서 다음 명령어를 실행하세요:

npx lingo.dev@latest run

이 명령어는:

  1. i18n.json 파일을 읽습니다.
  2. 번역이 필요한 파일을 찾습니다.
  3. 파일에서 번역 가능한 콘텐츠를 추출합니다.
  4. 구성된 LLM을 사용하여 추출된 콘텐츠를 번역합니다.
  5. 번역된 콘텐츠를 파일 시스템에 다시 작성합니다.

번역이 처음 생성될 때 i18n.lock 파일이 생성됩니다. 이 파일은 어떤 콘텐츠가 번역되었는지 추적하여 이후 실행 시 불필요한 재번역을 방지합니다.

예제

en/example.strings

/* Basic examples */
"welcome_message" = "Hello, world!";
"login_button" = "Log In";
"error_message" = "Something went wrong";

"user_profile_title" = "User Profile";

/* Escaped characters */
"quote_example" = "She said \"Hello world!\"";
"newline_example" = "First line\nSecond line";

/* Unicode and special characters */
"unicode_example" = "Hello 世界 🌍";
"emoji" = "👋 Hello! 🎉";
"accents" = "Café, naïve, résumé";

/* Valid entries */
"settings_title" = "Settings";
"save_button" = "Save";

es/example.strings

/* Basic examples */
"welcome_message" = "¡Hola, mundo!";
"login_button" = "Iniciar Sesión";
"error_message" = "Algo salió mal";

"user_profile_title" = "Perfil de Usuario";

/* Escaped characters */
"quote_example" = "Ella dijo \"Hola mundo!\"";
"newline_example" = "Primera línea\nSegunda línea";

/* Unicode and special characters */
"unicode_example" = "Hola 世界 🌍";
"emoji" = "👋 ¡Hola! 🎉";
"accents" = "Café, naïve, résumé";

/* Valid entries */
"settings_title" = "Configuración";
"save_button" = "Guardar";

i18n.json

{
  "version": "1.10",
  "locale": {
    "source": "en",
    "targets": ["es"]
  },
  "buckets": {
    "xcode-strings": {
      "include": ["./[locale]/example.strings"]
    }
  },
  "$schema": "https://lingo.dev/schema/i18n.json"
}

i18n.lock

version: 1
checksums:
  c0001027bc43a90fe59344ea57847e7a:
    welcome_message: 0468579ef2fbc83c9d520c2f2f1c5059
    login_button: 0029e5a35676c0051e761fcd046ef9ee
    error_message: a3cd2f01c073f1f5ff436d4b132d39cf
    user_profile_title: bee775ff7216747b2111e93cefa57ddc
    quote_example: c519c83fe2629c0e9a6e7a14f64b6317
    newline_example: ae9313a2231a16f17e2367a4e5b322ee
    backslash_example: acf69a7273edf9f932f66027f699bbbe
    mixed_escapes: 9285b600baf307f7c060e20dc5778fad
    tab_example: 1451b8323511459dac68316a2594bb82
    multiline_literal: a4c5d1c388a06e29d96833e4d2f14a26
    multiline_mixed: f5d741606567d78281bc455074eb8f6c
    multiline_with_quotes: c82ec05ec488644808917b9c958da8cc
    after_comment: b7c19db10622cb67d4dd28270e85a428
    after_multiline_comment: 759d0ffce80451996a5a45b33a0870cc
    long_value: a54e8485e571c671e35865ba72cbcaf5
    unicode_example: 2de42b1aef6d20b314928b9c2554759d
    emoji: 1b387c2b5ce6c2cd608081ebcb5e6a94
    accents: 8c054e17f9b960d9317ca110a6fedf8c
    spaces_only: 8af60e2ee58a2e1e42071066e9c225da
    many_quotes: e2ff57b8058ab2c03c5b07cf901a7a48
    missing_semicolon: b2b5f0c3f552a348188de51bd4fcf511
    settings_title: 8df6777277469c1fd88cc18dde2f1cc3
    save_button: f7a2929f33bc420195e59ac5a8bcd454