# Simple string localization in Kotlin Multiplatform

DevFeed: [Simple string localization in Kotlin Multiplatform](<https://devfeed.tech/articles/simple-string-localization-in-kotlin-multiplatform-24740.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/simple-string-localization-in-kmm-beaffc5e7a17?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-08-14T16:30:03Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [Localization (l10n)](<https://devfeed.tech/topics/localization.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Android](<https://devfeed.tech/topics/android.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [business logic](<https://devfeed.tech/topics/business-logic.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [article](<https://devfeed.tech/tags/article.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlin-multiplatform-mobile](<https://devfeed.tech/tags/kotlin-multiplatform-mobile.md>), [mobile](<https://devfeed.tech/tags/mobile.md>)

## AI overview

This tutorial explains how to access localized strings from Kotlin Multiplatform Mobile shared code while retaining native string localization on Android and iOS. It outlines the platforms' differing localization mechanisms and presents an approach for retrieving localized, formatted, and plural strings from shared code.

## Source excerpt

Kotlin Multiplatform Mobile gives us a lot of freedom on what to share and how to share between native mobile applications. Usually, it's just the shared business logic, and no user-facing things live in the common KMM module. But sometimes we need more ... This article will describe a simple (no 3rd party needed) way to access and use localized strings from the KMM module. This approach is based on the native string localization provided by Android and iOS applications, so no changes to strings management are needed from your side. Native localization iOS and Android have similar approaches to the localization of strings with some major differences in details. Let's do a quick recap to get context before diving into the KMM stuff. On both operating systems, we have all localizable strings extracted to files (one per language) in the form of key-value lists. Once the application is run on the user's device, the operating system detects the closest language file and uses it to render your app's UI. Rather straightforward. The main difference can be seen when it comes to using those strings in the code though. https://medium.com/media/cc9c336339f06c04a4b01f98ad707e2c/href On Android, you have a generated R class, which contains all string keys, accessible during the compilation, so you have an auto-completion and compile-time check for the existence of all strings you are trying to use. https://medium.com/media/fb7cfa6d362cd3fd353fa29bd35a64e1/href On iOS, you pass the string key to NSLocalizedString, which is resolved and localized during the runtime, so you don't have the auto-completion and compile-time check. String key is used as the default value. KMM localization To me, strings are one of the most user-facing parts of mobile applications, so I'm not sure that we should share it or have just one strings file in a KMM module. My take on it is that we should leave the power of strings to native platforms and developers. Even though, we still may need to access those