μž‘κ°€:
    생성:2026-11-03λ§ˆμ§€λ§‰ μ—…λ°μ΄νŠΈ:2026-11-03

    Prettier ν”ŒλŸ¬κ·ΈμΈ

    prettier-plugin-intlayerλŠ” Prettierκ°€ νŒŒμΌμ„ 포맷할 λ•Œλ§ˆλ‹€ λ²ˆμ—­ ν‚€λ₯Ό κ³ μ •λœ μˆœμ„œλ‘œ μ •λ ¬ν•©λ‹ˆλ‹€. diffλ₯Ό μž‘κ²Œ μœ μ§€ν•˜κ³ , 병합 μΆ©λŒμ„ 쀄이며, λˆ„λ½λœ λ‘œμΌ€μΌμ„ μ‰½κ²Œ λ°œκ²¬ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

    ts
    // μ „
    t({ en: "Hello", ru: "ΠŸΡ€ΠΈΠ²Π΅Ρ‚", fr: "Bonjour", "en-GB": "Hello", ar: "Ω…Ψ±Ψ­Ψ¨Ψ§" });
    
    // ν›„
    t({ en: "Hello", ar: "Ω…Ψ±Ψ­Ψ¨Ψ§", "en-GB": "Hello", fr: "Bonjour", ru: "ΠŸΡ€ΠΈΠ²Π΅Ρ‚" });
    

    μ„€μΉ˜

    bash
    npm install --save-dev prettier prettier-plugin-intlayer
    

    Prettier 3 이상이 ν•„μš”ν•©λ‹ˆλ‹€.

    ν”„λ‘œμ νŠΈμ—μ„œ 이미 Prettierλ₯Ό μ‚¬μš© 쀑인 경우 intlayer init prettier λͺ…령을 μ‹€ν–‰ν•˜λ©΄ ν”ŒλŸ¬κ·ΈμΈμ΄ μ„€μΉ˜λ˜κ³  섀정에 μžλ™μœΌλ‘œ μΆ”κ°€λ©λ‹ˆλ‹€.

    μ‚¬μš©λ²•

    Prettier μ„€μ • νŒŒμΌμ— ν”ŒλŸ¬κ·ΈμΈμ„ μΆ”κ°€ν•©λ‹ˆλ‹€:

    .prettierrc.json
    {
      "plugins": ["prettier-plugin-intlayer"]
    }
    

    μ½˜ν…μΈ  μ„ μ–Έ νŒŒμΌμ—λ§Œ μ μš©ν•˜λ €λ©΄ overrideλ₯Ό μ‚¬μš©ν•˜μ„Έμš”:

    .prettierrc.json
    {
      "overrides": [
        {
          "files": "*.content.{ts,tsx,js,jsx,mjs,cjs,json}",
          "options": {
            "plugins": ["prettier-plugin-intlayer"],
            "intlayerSortContentKeys": true
          }
        }
      ]
    }
    

    μ •λ ¬λ˜λŠ” λŒ€μƒ

    t(): λ‘œμΌ€μΌ

    κ³ μ •λœ(pinned) λ‘œμΌ€μΌμ΄ λ¨Όμ € μ˜΅λ‹ˆλ‹€(기본값은 en). λ‚˜λ¨Έμ§€ λ‘œμΌ€μΌμ€ μ•ŒνŒŒλ²³ μˆœμ„œλŒ€λ‘œ μ •λ ¬λ©λ‹ˆλ‹€.

    ts
    t({
      en: "Invitation not found",
      ar: "Ψ§Ω„Ψ―ΨΉΩˆΨ© غير Ω…ΩˆΨ¬ΩˆΨ―Ψ©",
      de: "Einladung nicht gefunden",
      "en-GB": "Invitation not found",
      fr: "Invitation introuvable",
      "he-IL": "Χ”Χ”Χ–ΧžΧ Χ” לא Χ ΧžΧ¦ΧΧ”",
    });
    

    plural(): CLDR μˆœμ„œ

    μΉ΄ν…Œκ³ λ¦¬λŠ” κ°€μž₯ μž‘μ€ μˆ˜λŸ‰λΆ€ν„° λŒ€μ²΄κ°’(fallback) 순으둜 μ •λ ¬λ©λ‹ˆλ‹€: zero, one, two, few, many, other.

    ts
    plural({
      one: "{{count}} вакансия",
      few: "{{count}} вакансии",
      many: "{{count}} вакансий",
      other: "{{count}} вакансий",
    });
    

    enu(): μ˜€λ¦„μ°¨μˆœ μž„κ³„κ°’

    쑰건은 숫자 순으둜 μ •λ ¬λœ ν›„ μ—°μ‚°μž 순(<1, <=1, 1, >=1, >1)으둜 μ •λ ¬λ©λ‹ˆλ‹€. fallback은 λ§ˆμ§€λ§‰μ— μœ„μΉ˜ν•©λ‹ˆλ‹€.

    ts
    enu({
      "<-1": "Less than minus one car",
      "0": "No cars",
      "2": "Two cars",
      ">=3": "Many cars",
      fallback: "Some cars",
    });
    

    λŸ°νƒ€μž„μ—μ„œλŠ” λ¨Όμ € μΌμΉ˜ν•˜λŠ” 쑰건이 μ μš©λ©λ‹ˆλ‹€. ν”ŒλŸ¬κ·ΈμΈμ€ λͺ¨λ“  μˆ˜λŸ‰μ΄ λ™μΌν•œ μ½˜ν…μΈ λ‘œ 확인될 λ•Œμ—λ§Œ μƒˆ μˆœμ„œλ₯Ό μ μš©ν•©λ‹ˆλ‹€. μˆœμ„œκ°€ 결과에 영ν–₯을 λ―ΈμΉ˜λŠ” 경우 κ°μ²΄λŠ” μž‘μ„±λœ μƒνƒœ κ·ΈλŒ€λ‘œ μœ μ§€λ©λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄ { '<1': …, '<=-2.3': … }μ—μ„œλŠ” '<1' ν‚€κ°€ λͺ¨λ“  음수λ₯Ό μ²˜λ¦¬ν•©λ‹ˆλ‹€.

    select(): μ•ŒνŒŒλ²³ μˆœμ„œ

    μΌ€μ΄μŠ€λŠ” μ•ŒνŒŒλ²³ μˆœμ„œλ‘œ μ •λ ¬λ˜λ©° fallback이 λ§ˆμ§€λ§‰μ— λ°°μΉ˜λ©λ‹ˆλ‹€.

    ts
    select({
      draft: "This post is a draft",
      published: "This post is live",
      scheduled: "This post is scheduled",
      fallback: "Unknown status",
    });
    

    fallbackμ΄λ‚˜ other ν‚€κ°€ μ—†λŠ” 경우 λ§ˆμ§€λ§‰ μΌ€μ΄μŠ€κ°€ fallback으둜 μ‚¬μš©λ©λ‹ˆλ‹€. ν•΄λ‹Ή μΌ€μ΄μŠ€λŠ” λ§ˆμ§€λ§‰μ— μœ μ§€λ˜κ³  이전 μΌ€μ΄μŠ€λ“€λ§Œ μ •λ ¬λ©λ‹ˆλ‹€.

    .content.json 파일

    μ§λ ¬ν™”λœ ν˜•νƒœλ„ λ™μΌν•œ λ°©μ‹μœΌλ‘œ μ •λ ¬λ©λ‹ˆλ‹€: { "nodeType": "translation", "translation": { … } }, 그리고 plural, enumeration, select λ…Έλ“œλ„ λ§ˆμ°¬κ°€μ§€μž…λ‹ˆλ‹€.

    μ½˜ν…μΈ  ν‚€ (선택 사항)

    intlayerSortContentKeys: trueλ₯Ό μ§€μ •ν•˜λ©΄ ν”ŒλŸ¬κ·ΈμΈμ΄ λ”•μ…”λ„ˆλ¦¬ content의 킀도 λͺ¨λ“  쀑첩 μˆ˜μ€€μ—μ„œ μ•ŒνŒŒλ²³μˆœμœΌλ‘œ μ •λ ¬ν•©λ‹ˆλ‹€. μ΄λŠ” *.content.* νŒŒμΌμ—λ§Œ μ μš©λ©λ‹ˆλ‹€.

    app.content.ts
    export default {
      key: "app",
      content: {
        description: t({ en: "…", fr: "…" }),
        footer: {
          copyright: "Β© Intlayer",
          links: [{ href: "/doc", label: t({ en: "Docs", fr: "Docs" }) }],
        },
        title: t({ en: "Hello", fr: "Bonjour" }),
      },
    } satisfies Dictionary;
    

    정렬은 각 헬퍼 ν•¨μˆ˜(t, plural, enu, select, cond, gender, md, insert, nest, file…)λ₯Ό 거쳐 λ‚΄λΆ€ κ°μ²΄κΉŒμ§€ μ μš©λ©λ‹ˆλ‹€. 각 헬퍼 자체의 ν‚€ κ΅¬μ‘°λŠ” κ³ μœ ν•œ μˆœμ„œλ₯Ό μœ μ§€ν•©λ‹ˆλ‹€. cond() 및 gender()에 μ „λ‹¬λœ ν‚€λŠ” λ§ˆμ§€λ§‰ ν‚€κ°€ fallback 역할을 ν•˜λ―€λ‘œ μˆœμ„œκ°€ μž¬μ •λ ¬λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. content와 같은 μˆ˜μ€€μ˜ ν•„λ“œ(key, title, locale…)λŠ” μ›λž˜ μƒνƒœλ₯Ό μœ μ§€ν•©λ‹ˆλ‹€.

    μ˜΅μ…˜

    μ˜΅μ…˜κΈ°λ³Έκ°’μ„€λͺ…
    intlayerPinnedLocales["en"]t()μ—μ„œ μš°μ„ μ μœΌλ‘œ μ•žμ— μœ μ§€ν•  λ‘œμΌ€μΌ λͺ©λ‘. λͺ¨λ“  λ‘œμΌ€μΌμ„ μ •λ ¬ν•˜λ €λ©΄ []λ₯Ό μ „λ‹¬ν•˜μ„Έμš”.
    intlayerSortContentKeysfalse*.content.* νŒŒμΌμ—μ„œ λ”•μ…”λ„ˆλ¦¬μ˜ μ½˜ν…μΈ  ν‚€ 및 μ€‘μ²©λœ 객체도 μ •λ ¬ν•©λ‹ˆλ‹€.

    λ³€κ²½λ˜μ§€ μ•ŠλŠ” λŒ€μƒ

    • μŠ€ν”„λ ˆλ“œ(...base), κ³„μ‚°λœ ν‚€([key]), λ©”μ„œλ“œ λ˜λŠ” 쀑볡 ν‚€κ°€ ν¬ν•¨λœ 객체.
    • CLDR μΉ΄ν…Œκ³ λ¦¬κ°€ μ•„λ‹Œ ν‚€λ₯Ό κ°€μ§„ plural() λ§΅.
    • μƒˆλ‘œμš΄ μˆœμ„œ 적용 μ‹œ ν™•μΈλ˜λŠ” μ½˜ν…μΈ κ°€ λ‹¬λΌμ§ˆ 수 μžˆλŠ” enu() λ§΅.
    • 헬퍼와 이름은 κ°™μ§€λ§Œ 객체가 μ•„λ‹Œ μΈμˆ˜κ°€ μ „λ‹¬λœ ν•¨μˆ˜ 호좜.

    주석은 ν•΄λ‹Ή 주석이 μ†ν•œ 킀와 ν•¨κ»˜ μ΄λ™ν•©λ‹ˆλ‹€.

    μ§€μ›λ˜λŠ” νŒŒμ„œ

    babel, babel-flow, babel-ts, typescript, flow, acorn, espree, meriyah, json, json5, jsonc. Vue, Svelte, Astro 파일의 <script> 블둝도 이 νŒŒμ„œλ“€μ„ 톡해 ν¬λ§·λ©λ‹ˆλ‹€.

    μ•Œλ €μ§„ μ œν•œ 사항. PrettierλŠ” νŒŒμ„œλ‹Ή 단 ν•˜λ‚˜μ˜ ν”ŒλŸ¬κ·ΈμΈλ§Œ μ‹€ν–‰ν•©λ‹ˆλ‹€. λ‹€λ₯Έ ν”ŒλŸ¬κ·ΈμΈλ„ JavaScript/TypeScript νŒŒμ„œλ₯Ό λŒ€μ²΄ν•˜λŠ” 경우(예: prettier-plugin-tailwindcss), λ§ˆμ§€λ§‰μ— λ‚˜μ—΄λœ ν”ŒλŸ¬κ·ΈμΈλ§Œ ν•΄λ‹Ή νŒŒμΌμ— μ μš©λ©λ‹ˆλ‹€. μΆ©λŒμ„ ν”Όν•˜λ €λ©΄ overrideλ₯Ό μ‚¬μš©ν•˜μ—¬ prettier-plugin-intlayer의 λ²”μœ„λ₯Ό *.content.* 파일둜 ν•œμ •ν•˜μ„Έμš”.