Token导航 LogoToken导航

Agent Skill · 前端设计

axiom-localization(公理定位)

axiom-localization 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

axiom-localization 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证为 MIT,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 1,647。

总安装 4,468周安装 179GitHub Stars 873下载 1,446核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:axiom-localization(公理定位)
来源仓库:https://github.com/charleswiltgen/axiom
仓库路径:skills/axiom-localization
安装命令:
npx skills add https://github.com/charleswiltgen/axiom --skill axiom-localization
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/charleswiltgen/axiom --skill axiom-localization

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理。可结合来源仓库、安装命令和原始 README 继续核验具体用法。

安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。axiom-localization 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/axiom-localization

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/charleswiltgen/axiom --skill axiom-localizatio…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

axiom-localization 怎么安装?

在终端执行 npx skills add https://github.com/charleswiltgen/axiom --skill axiom-localization。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

axiom-localization 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

axiom-localization 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

axiom-localization 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

axiom-localization 用的人多吗?

公开数据是累计安装 4,468 次,近一周安装 179 次,下载 1,446 次,GitHub 873 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

axiom-localization 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。
  • 需要许可证清楚、并且有第三方扫描结果的团队项目。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
axiom-localization

公理定位 · 本页

4,468873需要联网MIT通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Localization & Internationalization

Comprehensive guide to app localization using String Catalogs. Apple Design Award Inclusivity winners always support multiple languages with excellent RTL (Right-to-Left) support.

Overview

String Catalogs (.xcstrings) are Xcode 15's unified format for managing app localization. They replace legacy .strings and .stringsdict files with a single JSON-based format that's easier to maintain, diff, and integrate with translation workflows.

This skill covers String Catalogs, SwiftUI/UIKit localization APIs, plural handling, RTL support, locale-aware formatting, and migration strategies from legacy formats.

When to Use This Skill

  • Setting up String Catalogs in Xcode 15+
  • Localizing SwiftUI and UIKit apps
  • Handling plural forms correctly (critical for many languages)
  • Supporting RTL languages (Arabic, Hebrew)
  • Formatting dates, numbers, and currencies by locale
  • Migrating from legacy .strings/.stringsdict files
  • Preparing App Shortcuts and App Intents for localization
  • Debugging missing translations or incorrect plural forms

System Requirements

  • Xcode 15+ for String Catalogs (.xcstrings)
  • Xcode 26+ for automatic symbol generation, #bundle macro, and AI-powered comment generation
  • iOS 15+ for LocalizedStringResource
  • iOS 16+ for App Shortcuts localization
  • Earlier iOS versions use legacy .strings files

Part 1: String Catalogs (WWDC 2023/10155)

Creating a String Catalog

Method 1: Xcode Navigator

  1. File → New → File
  2. Choose "String Catalog"
  3. Name it (e.g., Localizable.xcstrings)
  4. Add to target

Method 2: Automatic Extraction

Xcode 15 can automatically extract strings from:

  • SwiftUI views (string literals in Text, Label, Button)
  • Swift code (String(localized:))
  • Objective-C (NSLocalizedString)
  • C (CFCopyLocalizedString)
  • Interface Builder files (.storyboard, .xib)
  • Info.plist values
  • App Shortcuts phrases

Build Settings Required:

  • "Use Compiler to Extract Swift Strings" → Yes
  • "Localization Prefers String Catalogs" → Yes

String Catalog Structure

Each entry has:

  • Key: Unique identifier (default: the English string)
  • Default Value: Fallback if translation missing
  • Comment: Context for translators
  • String Table: Organization container (default: "Localizable")

Example .xcstrings JSON:

{
  "sourceLanguage" : "en",
  "strings" : {
    "Thanks for shopping with us!" : {
      "comment" : "Label above checkout button",
      "localizations" : {
        "en" : {
          "stringUnit" : {
            "state" : "translated",
            "value" : "Thanks for shopping with us!"
          }
        },
        "es" : {
          "stringUnit" : {
            "state" : "translated",
            "value" : "¡Gracias por comprar con nosotros!"
          }
        }
      }
    }
  },
  "version" : "1.0"
}

Translation States

Xcode tracks state for each translation:

  • New (⚪) - String hasn't been translated yet
  • Needs Review (🟡) - Source changed, translation may be outdated
  • Reviewed (✅) - Translation approved and current
  • Stale (🔴) - String no longer found in source code

Workflow:

  1. Developer adds string → New
  2. Translator adds translation → Reviewed
  3. Developer changes source → Needs Review
  4. Translator updates → Reviewed
  5. Developer removes code → Stale

Part 2: SwiftUI Localization

LocalizedStringKey (Automatic)

SwiftUI views with String parameters automatically support localization:

// ✅ Automatically localizable
Text("Welcome to WWDC!")
Label("Thanks for shopping with us!", systemImage: "bag")
Button("Checkout") { }

// Xcode extracts these strings to String Catalog

How it works: SwiftUI uses LocalizedStringKey internally, which looks up strings in String Catalogs.

String(localized:) with Comments

For explicit localization in Swift code:

// Basic
let title = String(localized: "Welcome to WWDC!")

// With comment for translators
let title = String(localized: "Welcome to WWDC!",
                   comment: "Notification banner title")

// With custom table
let title = String(localized: "Welcome to WWDC!",
                   table: "WWDCNotifications",
                   comment: "Notification banner title")

// With default value (key ≠ English text)
let title = String(localized: "WWDC_NOTIFICATION_TITLE",
                   defaultValue: "Welcome to WWDC!",
                   comment: "Notification banner title")

Best practice: Always include comment to give translators context.

LocalizedStringResource (Deferred Localization)

For passing localizable strings to other functions:

import Foundation

struct CardView: View {
    let title: LocalizedStringResource
    let subtitle: LocalizedStringResource

    var body: some View {
        ZStack {
            RoundedRectangle(cornerRadius: 10.0)
            VStack {
                Text(title)      // Resolved at render time
                Text(subtitle)
            }
            .padding()
        }
    }
}

// Usage
CardView(
    title: "Recent Purchases",
    subtitle: "Items you've ordered in the past week."
)

Key difference: LocalizedStringResource defers lookup until used, allowing custom views to be fully localizable.

AttributedString with Markdown

// Markdown formatting is preserved across localizations
let subtitle = AttributedString(localized: "**Bold** and _italic_ text")

Part 3: UIKit & Foundation

NSLocalizedString Macro

// Basic
let title = NSLocalizedString("Recent Purchases", comment: "Button Title")

// With table
let title = NSLocalizedString("Recent Purchases",
                             tableName: "Shopping",
                             comment: "Button Title")

// With bundle
let title = NSLocalizedString("Recent Purchases",
                             tableName: nil,
                             bundle: .main,
                             value: "",
                             comment: "Button Title")

Bundle.localizedString

let customBundle = Bundle(for: MyFramework.self)
let text = customBundle.localizedString(forKey: "Welcome",
                                        value: nil,
                                        table: "MyFramework")

Custom Macros

// Objective-C
#define MyLocalizedString(key, comment) \
    [myBundle localizedStringForKey:key value:nil table:nil]

Info.plist Localization

Localize app name, permissions, etc.:

  1. Select Info.plist
  2. Editor → Add Localization
  3. Create InfoPlist.strings for each language:
// InfoPlist.strings (Spanish)
"CFBundleName" = "Mi Aplicación";
"NSCameraUsageDescription" = "La app necesita acceso a la cámara para tomar fotos.";

Part 4: Pluralization

Different languages have different plural rules:

  • English: 2 forms (one, other)
  • Russian: 3 forms (one, few, many)
  • Polish: 3 forms (one, few, other)
  • Arabic: 6 forms (zero, one, two, few, many, other)

SwiftUI Plural Handling

// Xcode automatically creates plural variations
Text("\(count) items")

// With custom formatting
Text("\(visitorCount) Recent Visitors")

In String Catalog:

{
  "strings" : {
    "%lld Recent Visitors" : {
      "localizations" : {
        "en" : {
          "variations" : {
            "plural" : {
              "one" : {
                "stringUnit" : {
                  "state" : "translated",
                  "value" : "%lld Recent Visitor"
                }
              },
              "other" : {
                "stringUnit" : {
                  "state" : "translated",
                  "value" : "%lld Recent Visitors"
                }
              }
            }
          }
        }
      }
    }
  }
}

XLIFF Export Format

When exporting for translation (File → Export Localizations):

Legacy (stringsdict):

<trans-unit id="/%lld Recent Visitors:dict/NSStringLocalizedFormatKey:dict/:string">
    <source>%#@recentVisitors@</source>
</trans-unit>

<trans-unit id="/%lld Recent Visitors:dict/recentVisitors:dict/one:dict/:string">
    <source>%lld Recent Visitor</source>
    <target>%lld Visitante Recente</target>
</trans-unit>

String Catalog (cleaner):

<trans-unit id="%lld Recent Visitors|==|plural.one">
    <source>%lld Recent Visitor</source>
    <target>%lld Visitante Recente</target>
</trans-unit>

<trans-unit id="%lld Recent Visitors|==|plural.other">
    <source>%lld Recent Visitors</source>
    <target>%lld Visitantes Recentes</target>
</trans-unit>

Substitutions with Plural Variables

// Multiple variables with different plural forms
let message = String(localized: "\(songCount) songs on \(albumCount) albums")

Xcode creates variations for each variable's plural form:

  • songCount: one, other
  • albumCount: one, other
  • Total combinations: 2 × 2 = 4 translation entries

Part 5: Device & Width Variations

Device-Specific Strings

Different text for different platforms:

// Same code, different strings per device
Text("Bird Food Shop")

String Catalog variations:

{
  "Bird Food Shop" : {
    "localizations" : {
      "en" : {
        "variations" : {
          "device" : {
            "applewatch" : {
              "stringUnit" : {
                "value" : "Bird Food"
              }
            },
            "other" : {
              "stringUnit" : {
                "value" : "Bird Food Shop"
              }
            }
          }
        }
      }
    }
  }
}

Result:

  • iPhone/iPad: "Bird Food Shop"
  • Apple Watch: "Bird Food" (shorter for small screen)

Width Variations

For dynamic type and size classes:

Text("Application Settings")

String Catalog can provide shorter text for narrow widths.


Part 6: RTL Support

Layout Mirroring

SwiftUI automatically mirrors layouts for RTL languages:

// ✅ Automatically mirrors for Arabic/Hebrew
HStack {
    Image(systemName: "chevron.right")
    Text("Next")
}

// iPhone (English): [>] Next
// iPhone (Arabic):  Next [<]

Leading/Trailing vs Left/Right

Always use semantic directions:

// ✅ Correct - mirrors automatically
.padding(.leading, 16)
.frame(maxWidth: .infinity, alignment: .leading)

// ❌ Wrong - doesn't mirror
.padding(.left, 16)
.frame(maxWidth: .infinity, alignment: .left)

Images and Icons

Mark images that should/shouldn't flip:

// ✅ Directional - mirrors for RTL
Image(systemName: "chevron.forward")

// ✅ Non-directional - never mirrors
Image(systemName: "star.fill")

// Custom images
Image("backButton")
    .flipsForRightToLeftLayoutDirection(true)

Testing in RTL Mode

Xcode Scheme:

  1. Edit Scheme → Run → Options
  2. Application Language: Arabic / Hebrew
  3. OR: App Language → Right-to-Left Pseudolanguage

Simulator: Settings → General → Language & Region → Preferred Language Order

SwiftUI Preview:

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
            .environment(\.layoutDirection, .rightToLeft)
            .environment(\.locale, Locale(identifier: "ar"))
    }
}

Part 7: Locale-Aware Formatting

DateFormatter

let formatter = DateFormatter()
formatter.locale = Locale.current  // ✅ Use current locale
formatter.dateStyle = .long
formatter.timeStyle = .short

let dateString = formatter.string(from: Date())

// US: "January 15, 2024 at 3:30 PM"
// France: "15 janvier 2024 à 15:30"
// Japan: "2024年1月15日 15:30"

Never hardcode date format strings:

// ❌ Wrong - breaks in other locales
formatter.dateFormat = "MM/dd/yyyy"

// ✅ Correct - adapts to locale
formatter.dateStyle = .short

NumberFormatter for Currency

let formatter = NumberFormatter()
formatter.locale = Locale.current
formatter.numberStyle = .currency

let priceString = formatter.string(from: 29.99)

// US: "$29.99"
// UK: "£29.99"
// Japan: "¥30" (rounds to integer)
// France: "29,99 €" (comma decimal, space before symbol)

MeasurementFormatter

let distance = Measurement(value: 100, unit: UnitLength.meters)

let formatter = MeasurementFormatter()
formatter.locale = Locale.current

let distanceString = formatter.string(from: distance)

// US: "328 ft" (converts to imperial)
// Metric countries: "100 m"

Locale-Specific Sorting

let names = ["Ångström", "Zebra", "Apple"]

// ✅ Locale-aware sort
let sorted = names.sorted { (lhs, rhs) in
    lhs.localizedStandardCompare(rhs) == .orderedAscending
}

// Sweden: ["Ångström", "Apple", "Zebra"]  (Å comes first in Swedish)
// US: ["Ångström", "Apple", "Zebra"]      (Å treated as A)

Part 8: App Shortcuts Localization

Phrases with Parameters

import AppIntents

struct ShowTopDonutsIntent: AppIntent {
    static var title: LocalizedStringResource = "Show Top Donuts"

    @Parameter(title: "Timeframe")
    var timeframe: Timeframe

    static var parameterSummary: some ParameterSummary {
        Summary("\(.applicationName) Trends for \(\.$timeframe)") {
            \.$timeframe
        }
    }
}

String Catalog automatically extracts:

  • Intent title
  • Parameter names
  • Phrase templates with placeholders

Localized phrases:

English: "Food Truck Trends for this week"
Spanish: "Tendencias de Food Truck para esta semana"

AppShortcutsProvider Localization

struct FoodTruckShortcuts: AppShortcutsProvider {
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: ShowTopDonutsIntent(),
            phrases: [
                "\(.applicationName) Trends for \(\.$timeframe)",
                "Show trending donuts for \(\.$timeframe) in \(.applicationName)",
                "Give me trends for \(\.$timeframe) in \(.applicationName)"
            ]
        )
    }
}

Xcode extracts all 3 phrases into String Catalog for translation.


Part 9: Migration from Legacy

Converting.strings to.xcstrings

Automatic migration:

  1. Select .strings file in Navigator
  2. Editor → Convert to String Catalog
  3. Xcode creates .xcstrings and preserves translations

Manual approach:

  1. Create new String Catalog
  2. Build project (Xcode extracts strings from code)
  3. Import translations via File → Import Localizations (XLIFF)
  4. Delete old .strings files

Converting.stringsdict

Plural files automatically merge:

  1. Keep .strings and .stringsdict together
  2. Convert → Both merge into single .xcstrings
  3. Plural variations preserved

Gradual Migration Strategy

Phase 1: New code uses String Catalogs

  • Create Localizable.xcstrings
  • Write new code with String(localized:)
  • Keep legacy .strings files for old code

Phase 2: Migrate existing strings

  • Convert one .strings table at a time
  • Test translations after each conversion
  • Update code using old NSLocalizedString calls

Phase 3: Remove legacy files

  • Delete .strings and .stringsdict files
  • Verify all strings in String Catalog
  • Submit to App Store

Coexistence: .strings and .xcstrings work together - Xcode checks both.


Common Mistakes

Hardcoded Strings

// ❌ Wrong - not localizable
Text("Welcome")
let title = "Settings"

// ✅ Correct - localizable
Text("Welcome")  // SwiftUI auto-localizes
let title = String(localized: "Settings")

Concatenating Localized Strings

// ❌ Wrong - word order varies by language
let message = String(localized: "You have") + " \(count) " + String(localized: "items")

// ✅ Correct - single localizable string with substitution
let message = String(localized: "You have \(count) items")

Why wrong: Some languages put numbers before nouns, some after.

Missing Plural Forms

// ❌ Wrong - grammatically incorrect for many languages
Text("\(count) item(s)")

// ✅ Correct - proper plural handling
Text("\(count) items")  // Xcode creates plural variations

Ignoring RTL

// ❌ Wrong - breaks in RTL languages
.padding(.left, 20)
HStack {
    backButton
    Spacer()
    title
}

// ✅ Correct - mirrors automatically
.padding(.leading, 20)
HStack {
    backButton  // Appears on right in RTL
    Spacer()
    title
}

Wrong Date/Number Formats

// ❌ Wrong - US-only format
let formatter = DateFormatter()
formatter.dateFormat = "MM/dd/yyyy"

// ✅ Correct - adapts to locale
formatter.dateStyle = .short
formatter.locale = Locale.current

Forgetting Comments

// ❌ Wrong - translator has no context
String(localized: "Confirm")

// ✅ Correct - clear context
String(localized: "Confirm", comment: "Button to confirm delete action")

Impact: "Confirm" could mean "verify" or "acknowledge" - context matters for accurate translation.


Troubleshooting

Strings not appearing in String Catalog

Cause: Build settings not enabled

Solution:

  1. Build Settings → "Use Compiler to Extract Swift Strings" → Yes
  2. Clean Build Folder (Cmd+Shift+K)
  3. Build project

Translations not showing in app

Cause 1: Language not added to project

  1. Project → Info → Localizations → + button
  2. Add target language

Cause 2: String marked as "Stale"

  • Remove stale strings or verify code still uses them

Plural forms incorrect

Cause: Using String.localizedStringWithFormat instead of String Catalog

Solution: Use String Catalog's automatic plural handling:

// ✅ Correct
Text("\(count) items")

// ❌ Wrong
Text(String.localizedStringWithFormat(NSLocalizedString("%d items", comment: ""), count))

XLIFF export missing strings

Cause: "Localization Prefers String Catalogs" not set

Solution:

  1. Build Settings → "Localization Prefers String Catalogs" → Yes
  2. Export Localizations again

Generated symbols not appearing (Xcode 26+)

Cause 1: Build setting not enabled

Solution:

  1. Build Settings → "Generate String Catalog Symbols" → Yes
  2. Clean Build Folder (Cmd+Shift+K)
  3. Rebuild project

Cause 2: String not manually added to catalog

Solution: Symbols only generate for manually-added strings (+ button in String Catalog). Auto-extracted strings don't generate symbols.

#bundle macro not working (Xcode 26+)

Cause: Wrong syntax or missing import

Solution:

import Foundation  // Required for #bundle
Text("My Collections", bundle: #bundle, comment: "Section title")

Verify you're using #bundle not .module.

Refactoring to symbols fails (Xcode 26+)

Cause 1: String not in String Catalog

  1. Ensure string exists in .xcstrings file
  2. Build project to refresh catalog
  3. Try refactoring again

Cause 2: Build setting not enabled

  • Enable "Generate String Catalog Symbols" in Build Settings
  • Clean and rebuild

Part 10: Xcode 26 Localization Enhancements

Xcode 26 introduces type-safe localization with generated symbols, automatic comment generation using on-device AI, and improved Swift Package support with the #bundle macro. Based on WWDC 2025 session 225 "Explore localization with Xcode".

Generated Symbols (Type-Safe Localization)

The problem: String-based localization fails silently when typos occur.

// ❌ Typo - fails silently at runtime
Text("App.HomeScren.Title")  // Missing 'e' in Screen

The solution: Xcode 26 generates type-safe symbols from manually-added strings.

How It Works
  1. Add strings manually to String Catalog using the + button
  2. Enable build setting: "Generate String Catalog Symbols" (ON by default in new projects)
  3. Use symbols instead of strings
// ✅ Type-safe - compiler catches typos
Text(.appHomeScreenTitle)
Symbol Generation Rules
String TypeGenerated Symbol TypeUsage Example
No placeholdersStatic propertyText(.introductionTitle)
With placeholdersFunction with labeled arguments.subtitle(friendsPosts: 42)

Key naming conversion:

  • App.HomeScreen.Title → .appHomeScreenTitle
  • Periods removed, camel-cased
  • Available on LocalizedStringResource
Code Examples
// SwiftUI views
struct ContentView: View {
    var body: some View {
        NavigationStack {
            Text(.introductionTitle)
                .navigationSubtitle(.subtitle(friendsPosts: 42))
        }
    }
}

// Foundation String
let message = String(localized: .curatedCollection)

// Custom views with LocalizedStringResource
struct CollectionDetailEditingView: View {
    let title: LocalizedStringResource

    init(title: LocalizedStringResource) {
        self.title = title
    }

    var body: some View {
        Text(title)
    }
}

CollectionDetailEditingView(title: .editingTitle)

Automatic Comment Generation

Xcode 26 uses an on-device model to automatically generate contextual comments for localizable strings.

Enabling the Feature
  1. Open Xcode Settings → Editing
  2. Enable "automatically generate string catalog comments"
  3. New strings added to code automatically receive generated comments
Example

For a button string, Xcode generates:

"The text label on a button to cancel the deletion of a collection"

This context helps translators understand where and how the string is used.

XLIFF Export

Auto-generated comments are marked in exported XLIFF files:

<trans-unit id="Grand Canyon" xml:space="preserve">
    <source>Grand Canyon</source>
    <target state="new">Grand Canyon</target>
    <note from="auto-generated">Suggestion for searching landmarks</note>
</trans-unit>

Benefits:

  • Saves developer time writing translator context
  • Provides consistent, clear descriptions
  • Improves translation quality

Swift Package & Framework Localization

The Problem

SwiftUI uses the .main bundle by default. Swift Packages and frameworks need to reference their own bundle:

// ❌ Wrong - uses main bundle, strings not found
Text("My Collections", comment: "Section title")
The Solution: #bundle Macro (NEW in Xcode 26)

The #bundle macro automatically references the correct bundle for the current target:

// ✅ Correct - automatically uses package/framework bundle
Text("My Collections", bundle: #bundle, comment: "Section title")

Key advantages:

  • Works in main app, frameworks, and Swift Packages
  • Backwards-compatible with older OS versions
  • Eliminates manual .module bundle management
With Custom Table Names
// Main app
Text("My Collections",
     tableName: "Discover",
     comment: "Section title")

// Framework or Swift Package
Text("My Collections",
     tableName: "Discover",
     bundle: #bundle,
     comment: "Section title")

Custom Table Symbol Access

When using multiple String Catalogs for organization:

Default "Localizable" Table

Symbols are directly accessible on LocalizedStringResource:

Text(.welcomeMessage)  // From Localizable.xcstrings

Note: Xcode automatically resolves symbols from the default "Localizable" table. Explicit table selection is rarely needed—use it only for debugging or testing specific catalogs.

Custom Tables

Symbols are nested in the table namespace:

// From Discover.xcstrings
Text(Discover.featuredCollection)

// From Settings.xcstrings
Text(Settings.privacyPolicy)

Organization strategy for large apps:

  • Localizable.xcstrings - Core app strings
  • FeatureName.xcstrings - Feature-specific strings (e.g., Onboarding, Settings, Discover)
  • Benefits: Easier to manage, clearer ownership, better XLIFF organization

Two Localization Workflows

Xcode 26 supports two complementary workflows:

Workflow 1: String Extraction (Recommended for new projects)

Process:

  1. Write strings directly in code
  2. Use SwiftUI views (Text, Button) and String(localized:)
  3. Xcode automatically extracts to String Catalog
  4. Leverage automatic comment generation

Pros: Simple initial setup, immediate start

Cons: Less control over string organization

// ✅ String extraction workflow
Text("Welcome to WWDC!", comment: "Main welcome message")
Workflow 2: Generated Symbols (Recommended as complexity grows)

Process:

  1. Manually add strings to String Catalog
  2. Reference via type-safe symbols
  3. Organize into custom tables

Pros: Better control, type safety, easier to maintain across frameworks

Cons: Requires planning string catalog structure upfront

// ✅ Generated symbols workflow
Text(.welcomeMessage)
WorkflowBest ForTrade-offs
String ExtractionNew projects, simple apps, prototypingAutomatic extraction, less control over organization
Generated SymbolsLarge apps, frameworks, multiple teamsType safety, better organization, requires upfront planning

Refactoring Between Workflows

Xcode 26 allows converting between workflows without manual rewriting.

Converting Strings to Symbols
  1. Right-click on a string literal in code
  2. Select "Refactor > Convert Strings to Symbols"
  3. Preview all affected locations
  4. Customize symbol names before confirming
  5. Apply to entire table or individual strings

Example:

// Before
Text("Welcome to WWDC!", comment: "Main welcome message")

// After refactoring
Text(.welcomeToWWDC)

Benefits:

  • Batch conversion of entire String Catalogs
  • Preview changes before applying
  • Maintain localization without code rewrites

Implementation Checklist

After adopting Xcode 26 generated symbols, verify:

Build Configuration:

  • "Generate String Catalog Symbols" build setting enabled
  • Project builds without "Cannot find 'symbolName' in scope" errors
  • Clean build succeeds (Cmd+Shift+K, then Cmd+B)

String Catalog Setup:

  • Strings manually added to catalog using + button (not auto-extracted)
  • Symbol names follow conventions (camelCase, no periods)
  • Custom tables organized by feature (if using multiple catalogs)

Swift Package Integration:

  • All Text() and String(localized:) calls in packages use bundle: #bundle
  • Import Foundation added where #bundle is used
  • Tested package builds independently and as dependency

Refactoring & Migration:

  • Tested refactoring tool on sample strings
  • Preview showed expected changes before applying
  • Old string-based calls still work during transition period

Optional Features:

  • Automatic comment generation enabled in Xcode Settings → Editing (optional)
  • Tested AI-generated comments for accuracy
  • XLIFF export includes auto-generated comments

Testing:

  • Symbols resolve correctly in SwiftUI previews
  • Localization works across all supported languages
  • App runs on minimum supported iOS version

Resources

WWDC: 2025-225, 2023-10155, 2022-10110

Docs: /xcode/localization, /xcode/localizing-and-varying-text-with-a-string-catalog

Skills: axiom-app-intents-ref, axiom-hig, axiom-accessibility-diag

平台分布

Claude Code

29.25%
按下载量换算423

Codex

23.71%
按下载量换算343

OpenCode

20.14%
按下载量换算291

Antigravity

12.91%
按下载量换算187

Cursor

8.02%
按下载量换算116

Gemini CLI

4.39%
按下载量换算63

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

继续浏览同类 Skills