Text("Hello \(user)") How Do i localice Hello?
Asked on 06/14/2025
1 search
To localize the text "Hello (user)" in SwiftUI, you can use the localization features provided by Xcode. Here's a general approach based on the session "Code-along: Explore localization with Xcode" from WWDC:
-
Add a String Catalog: Start by adding a string catalog to your project. This can be done through the File menu in Xcode. The default name is "Localizable", and it should be placed in the Resources group.
-
Localize Strings: Most SwiftUI APIs, including
Text
, are localizable by default. You can useString.localized
to make strings available for localization. For example, you can define your string in the string catalog and use it in your SwiftUI code. -
Use Interpolation: For strings with interpolated variables, such as "Hello (user)", you can define a placeholder in your string catalog. Xcode will generate a function for strings with placeholders, using the placeholder name as the argument label.
-
Generate Symbols: Xcode can generate symbols for manually added strings, which can be used anywhere a localized string resource is needed, including SwiftUI views like
Text
orButton
.
For more detailed steps, you can refer to the session Code-along: Explore localization with Xcode (00:01:00) where these concepts are demonstrated.

Code-along: Explore localization with Xcode
Learn how to localize your app into additional languages using Xcode. We’ll walk step-by-step through the process of creating a String Catalog, translating text, and exchanging files with external translators. You’ll learn best practices for providing necessary context to translators and how Xcode can help to provide this information automatically. For larger projects, we’ll also dive into techniques to manage complexity and streamline string management using type-safe Swift code.

Build multilingual-ready apps
Ensure your app works properly and effectively for multilingual users. Learn best practices for text input, display, search, and formatting. Get details on typing in multiple languages without switching between keyboards. And find out how the latest advances in the String Catalog can make localization even easier.

Meet the Translation API
Discover how you can translate text across different languages in your app using the new Translation framework. We’ll show you how to quickly display translations in the system UI, and how to translate larger batches of text for your app’s UI.