← 返回 Skills 市场
soponcd

I18n Swift

作者 soponcd · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
127
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install i18n-swift
功能描述
Swift internationalization patterns, String(localized:) usage, and semantic key naming for macOS/iOS apps
使用说明 (SKILL.md)

Swift Internationalization

Expert-level Swift i18n patterns for macOS/iOS applications. Covers string localization, semantic key naming, and best practices.

When: to Use

Use this skill when:

  • Adding localized strings to SwiftUI views
  • Creating new localization keys
  • Writing String(localized:) calls
  • Organizing Localizable.strings files
  • Reviewing i18n implementation in Swift projects

Core Principles

1. String(localized:) Pattern

// Always use String(localized:) for user-facing text
Text(String(localized: "common.save"))
Button(String(localized: "sidebar.today"))

// Never hardcode strings
Text("Save")  // ❌ Wrong

2. Semantic Key Naming

Use domain.feature.key pattern:

// Good: Semantic keys
"app.name" = "TimeFlow"
"common.save" = "Save"
"sidebar.today" = "Today"
"settings.theme.title" = "Theme"

// Bad: Non-semantic keys
"saveButton" = "Save"
"viewTitle1" = "Today"
"themeTitle" = "Theme"

3. Localizable.strings Organization

Group by domain with MARK comments:

/*
 Localizable.strings
 TimeFlow
*/

// MARK: - App
"app.name" = "TimeFlow";

// MARK: - Common
"common.delete" = "Delete";
"common.save" = "Save";
"common.cancel" = "Cancel";

// MARK: - Sidebar
"sidebar.today" = "Today";
"sidebar.settings" = "Settings";
"sidebar.daily_note" = "Daily Note";

// MARK: - GTD Navigation
"gtd.inbox" = "Inbox";
"gtd.today" = "Today";
"gtd.projects" = "Projects";

Key Naming Conventions

Domain Feature Examples
app - app.name
common delete, save, cancel common.delete, common.save
sidebar today, settings, search sidebar.today, sidebar.settings
`home`` today, progress, timeline home.today, home.progress
gtd inbox, next, projects gtd.inbox, gtd.next
settings theme, language, sync settings.theme.title
sync idle, syncing, failed sync.idle, sync.syncing

SwiftUI Usage Patterns

Text Component

struct TodayView: View {
    var body: some View {
        VStack {
            Text(String(localized: "home.today"))
                .font(.title)

            Text(String(localized: "home.no_events"))
                .foregroundStyle(.secondary)
        }
    }
}

Button with Localized String

Button(String(localized: "common.save")) {
    // Save action
}
.disabled(isSaving)

Navigation Titles

NavigationLink(destination: SettingsView()) {
    Label(String(localized: "sidebar.settings"), systemImage: .gear)
}

Best Practices

Practice Reason
Use String(localized:) Prevents hardcoding, enables i18n
Semantic key names Self-documenting, easier maintenance
Group with // MARK: Organized, searchable strings files
Use domain.feature.key Clear ownership, prevents collisions
Update all languages together Prevents missing translations
Avoid format strings in keys Use Swift interpolation instead

String Interpolation

// Good: Use Swift interpolation
let message = String(localized: "sync.completed.count")
    .replacingOccurrences(of: "{count}", with: "\(count)")

// Alternative: Use String(format:) for localized format strings
let formatted = String(
    localized: "sync.completed.count",
    comment: "Number of items synced"
)

// Localizable.strings entry:
// "sync.completed.count" = "Synced %d items";

Common Pitfalls

Pitfall Consequence Prevention
Hardcoded strings Can't localize Always use String(localized:)
Non-semantic keys Difficult to maintain Use domain.feature.key pattern
Missing translations Shows key name Add entries to all .strings files
Format strings in keys Ambiguous values Use Swift interpolation
Duplicate keys Confusing maintenance Search before adding

Testing Patterns

func testLocalizationKeys() {
    // Verify all keys exist in Localizable.strings
    let keys = ["app.name", "common.save", "sidebar.today"]
    for key in keys {
        let localized = String(localized: key)
        XCTAssertNotEqual(localized, key, "Key not found: \(key)")
    }
}

Running Tests

# Test localization
xcodebuild test -scheme YourApp \
  -destination 'platform=macOS' \
  -only-testing:'YourAppTests/LocalizationTests/testKeysExist'
安全使用建议
This skill is essentially a best-practices guide for Swift/iOS localization and appears coherent and low-risk. Before enabling it for autonomous use, consider: (1) the SKILL.md includes an example xcodebuild command — if you let the agent execute commands it could run tests in your workspace, so only allow execution when you trust the agent and working directory; (2) review any generated or suggested strings before applying them to your repo (pluralization/formatting choices may need manual review); and (3) the source is listed as a GitHub path — if provenance matters, inspect that repo to confirm the content. Otherwise this instruction-only skill does not request sensitive access and is internally consistent.
功能分析
Type: OpenClaw Skill Name: i18n-swift Version: 1.0.0 The skill bundle provides standard documentation and best practices for Swift internationalization (i18n) in iOS/macOS development. All code snippets and instructions in SKILL.md are aligned with legitimate development patterns, and the included shell command for xcodebuild is a standard testing utility with no signs of malicious intent or data exfiltration.
能力评估
Purpose & Capability
Name/description (Swift i18n, String(localized:), key naming) match the SKILL.md content. The skill requests no binaries, env vars, or config paths — appropriate for a documentation/instruction skill.
Instruction Scope
The SKILL.md contains coding patterns, examples, tests, and an example xcodebuild command; it does not instruct the agent to read unrelated files, exfiltrate data, or access credentials. The only runtime action shown (xcodebuild test) is directly relevant to testing localization and is presented as an example.
Install Mechanism
No install spec or code files are present; the skill is instruction-only so nothing is written to disk or downloaded during install.
Credentials
The skill declares no environment variables, secrets, or credentials. Nothing in the instructions requires access to external services or unrelated credentials.
Persistence & Privilege
always is false and the skill does not request elevated or persistent privileges. Autonomous invocation is allowed (platform default) but not combined with other privilege or credential requests.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install i18n-swift
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /i18n-swift 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of the i18n-swift skill. - Provides guidance on Swift internationalization for macOS/iOS apps, including String(localized:) usage. - Details semantic key naming conventions (domain.feature.key) and organization for Localizable.strings. - Offers best practices and common pitfalls for localized string management. - Includes sample SwiftUI usage patterns and testing strategies for localization keys.
元数据
Slug i18n-swift
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

I18n Swift 是什么?

Swift internationalization patterns, String(localized:) usage, and semantic key naming for macOS/iOS apps. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 127 次。

如何安装 I18n Swift?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install i18n-swift」即可一键安装,无需额外配置。

I18n Swift 是免费的吗?

是的,I18n Swift 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

I18n Swift 支持哪些平台?

I18n Swift 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 I18n Swift?

由 soponcd(@soponcd)开发并维护,当前版本 v1.0.0。

💬 留言讨论