Swift Markdown Kit · DOCS

Localization

Localization

What gets translated

The SDK ships English and Simplified Chinese for the words it puts on screen itself — the copy button on a code block, the reasoning fold's header, the accessibility labels on message actions. Rendered Markdown is the author's text and is never translated.

Nothing needs turning on. Leave the string options unset and every reader gets the language their device is set to, falling back to English:

let options = MarkdownRenderOptions()

Pinning a language

If your app has its own language picker, point the SDK at it rather than at iOS:

MarkdownRenderLocalization.language = .simplifiedChinese

.automatic is the default and follows the device. .custom(_:) reaches any localization the SDK ships, and resolves script and region variants the way Foundation does, so "zh-CN" and "zh-Hans-CN" both land on Simplified Chinese:

MarkdownRenderLocalization.language = .custom("zh-CN")

A language the SDK does not ship falls back to English rather than showing raw lookup keys.

Set it during startup, before you build the options you hand to a renderer. The strings are read when an options value is constructed, so a later change does not reach back into options that already exist.

It follows the device, not your app

Worth knowing, because it is the opposite of how iOS treats frameworks by default. iOS holds every framework in a process to the app's own declared localizations. An app that hardcodes its Chinese strings — rather than shipping a zh-Hans.lproj — therefore declares English and nothing else, and every framework it loads is held to English, on a device set to Chinese.

The SDK resolves against the device's preferred languages instead, so it is translated whether or not your app ever declared a localization. If you would rather it follow your app, pin language explicitly.

Your own wording always wins

The localized strings are the defaults of the matching options. Pass one and you get exactly what you passed, in every language:

var options = MarkdownRenderOptions(copyText: "拷贝")
options.markdown.reasoning = MarkdownChatReasoningConfiguration(
    thinkingLabel: "Working…"
)

So an app that has already translated these words keeps its own wording, and one that has not gets the SDK's.

Which languages ship

let available = MarkdownRenderLocalization.availableLanguages  // ["en", "zh-Hans"]

The resolved strings are readable too, which is what to use if you are building your own chrome around the renderer and want it to match:

let copyLabel = MarkdownRenderLocalization.codeCopy
let thinkingLabel = MarkdownRenderLocalization.reasoningThinking

What is not translated

Licensing and renderer errors are integrator diagnostics — they name file names, build settings and scripts — so they stay in English wherever your device is set. They are meant for you, not for your reader.