Localization

KeyboardKit supports 60+ locales.

๐ŸŒ

Flexible localization support is an important part of a software keyboard, and should make it possible to localize the entire keyboard.

KeyboardKit defines keyboard-specific languages, where each has localized strings, assets, and locale-specific information. KeyboardKit also extends the native Locale with additional capabilities.

KeyboardKit Pro unlocks localized keyboards and services for all locales in your license. Information about Pro features can be found at the end of this article.

Supported locales

KeyboardKit supports 61 locales:

๐Ÿ‡ฆ๐Ÿ‡ฑ ๐Ÿ‡ฆ๐Ÿ‡ช ๐Ÿ‡ฆ๐Ÿ‡ฒ ๐Ÿ‡ง๐Ÿ‡พ ๐Ÿ‡ง๐Ÿ‡ฌ ๐Ÿ‡ฆ๐Ÿ‡ฉ ๐Ÿณ๏ธ ๐Ÿ‡ญ๐Ÿ‡ท ๐Ÿ‡จ๐Ÿ‡ฟ ๐Ÿ‡ฉ๐Ÿ‡ฐ ๐Ÿ‡ณ๐Ÿ‡ฑ ๐Ÿ‡ง๐Ÿ‡ช ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ช๐Ÿ‡ช ๐Ÿ‡ซ๐Ÿ‡ด ๐Ÿ‡ต๐Ÿ‡ญ ๐Ÿ‡ซ๐Ÿ‡ฎ ๐Ÿ‡ซ๐Ÿ‡ท ๐Ÿ‡ง๐Ÿ‡ช ๐Ÿ‡จ๐Ÿ‡ญ ๐Ÿ‡ฌ๐Ÿ‡ช ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ฆ๐Ÿ‡น ๐Ÿ‡จ๐Ÿ‡ญ ๐Ÿ‡ฌ๐Ÿ‡ท ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ฎ๐Ÿ‡ฑ ๐Ÿ‡ญ๐Ÿ‡บ ๐Ÿ‡ฎ๐Ÿ‡ธ ๐Ÿ‡ฎ๐Ÿ‡ฉ ๐Ÿ‡ฎ๐Ÿ‡ช ๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ‡ฐ๐Ÿ‡ฟ ๐Ÿ‡น๐Ÿ‡ฏ ๐Ÿ‡น๐Ÿ‡ฏ ๐Ÿ‡น๐Ÿ‡ฏ ๐Ÿ‡ฑ๐Ÿ‡ป ๐Ÿ‡ฑ๐Ÿ‡น ๐Ÿ‡ฒ๐Ÿ‡ฐ ๐Ÿ‡ฒ๐Ÿ‡พ ๐Ÿ‡ฒ๐Ÿ‡น ๐Ÿ‡ฒ๐Ÿ‡ณ ๐Ÿ‡ณ๐Ÿ‡ด ๐Ÿ‡ฎ๐Ÿ‡ท ๐Ÿ‡ต๐Ÿ‡ฑ ๐Ÿ‡ต๐Ÿ‡น ๐Ÿ‡ง๐Ÿ‡ท ๐Ÿ‡ท๐Ÿ‡ด ๐Ÿ‡ท๐Ÿ‡บ ๐Ÿ‡ท๐Ÿ‡ธ ๐Ÿ‡ท๐Ÿ‡ธ ๐Ÿ‡ธ๐Ÿ‡ฐ ๐Ÿ‡ธ๐Ÿ‡ฎ ๐Ÿ‡ช๐Ÿ‡ธ ๐Ÿ‡ฐ๐Ÿ‡ช ๐Ÿ‡ธ๐Ÿ‡ช ๐Ÿ‡น๐Ÿ‡ท ๐Ÿ‡บ๐Ÿ‡ฆ ๐Ÿ‡บ๐Ÿ‡ฟ

Each keyboard locale refers to a native Locale and has additional keyboard-specific information, as well as localized assets and strings that can be translated with the KKL10n enum.

Locale extensions

KeyboardKit extends the native Locale with more functionality.

Direction info

KeyboardKit lets you get the line and character direction of a locale:

let english = KeyboardLocale.english.locale
let persian = KeyboardLocale.persian.locale
let swedish = KeyboardLocale.swedish.locale

english.isLeftToRight  // true
english.isRightToLeft  // false
persian.isLeftToRight  // false
persian.isRightToLeft  // true
swedish.isTopToBottom  // false

english.lineDirection  // .leftToRight
persian.lineDirection  // .rightToLeft
swedish.lineDirection  // .leftToRight

Flag info

KeyboardKit lets you get the flag of a locale:

english.locale.flag    // ๐Ÿ‡บ๐Ÿ‡ธ
persian.locale.flag    // ๐Ÿ‡ฎ๐Ÿ‡ท
swedish.flag           // ๐Ÿ‡ธ๐Ÿ‡ช

Localized name

KeyboardKit lets you get and use the localized names of a locale:

english.localizedName              // English (United States)
swedish.localizedName(in: english) // Swedish (Sweden)
swedish.localizedName(in: swedish) // Svenska (Sverige)

Sorting

KeyboardKit also provide convenient Locale collection sorted extensions.

How to get the current keyboard locale

You can get the current locale and all available locales with KeyboardContextโ€™s .locale and .locales.

These properties return raw Locales, since a keyboard extension is not limited to the KeyboardLocale model. The context also has optional, KeyboardLocale-specific functions.

How to change keyboard locale

You can change the keyboard locale for a KeyboardContext by setting locale to a new locale, or use the convenience functions that support KeyboardLocale.

If the context locales has multiple values, you can switch locale using selectNextLocale() or using a LocaleContextMenu view that lets the user select a locale.

Setting the locale will update the controllerโ€™s primaryLanguage, which controls things like spellchecking and text direction. It will also set the display name in the system keyboard switcher.

LTR and RTL locales

KeyboardKit supports LTR (Left-To-Right) and RTL (Right-To-Left) locales.

You donโ€™t need to configure your keyboard to support RTL. Just change the keyboard locale as explained above, and KeyboardKit will automatically adjust the text direction.

How to translate localized content

Each KeyboardLocale has a localized strings file in Resources/<id>.lproj.

Localized strings can be translated using the KKL10n enum. For instance, this translates the text for the numeric button key for the current locale:

let translation = KKL10n.keyboardTypeNumeric.text

Besides localized strings, you can get flags for a keyboard locales, using the flag property. You can also use the contextโ€™s localePresentationLocale property to set how locales are displayed.

๐Ÿ‘‘ Pro features

KeyboardKit Pro unlocks a localized InputSet, KeyboardLayoutProvider and CalloutActionProvider for every KeyboardLocale that the license unlocks.

This means that KeyboardKit Pro can create fully localized SystemKeyboard for all supported locales.

Documentation

The information on this page is shortened to be easier to overview. For more information about this feature, code samples, etc., please see the online documentation.