Localization

RSS for tag

Localization is the process of adapting and translating your app to multiple languages.

Localization Documentation

Posts under Localization tag

137 Posts
Sort by:
Post not yet marked as solved
0 Replies
220 Views
Since Xcode 15.1, when compiling SwiftUI previews (using #Preview macro), strings that are unique to #Preview declarations are getting extracted and processed to the application's localizable strings catalog. In Xcode 15.0.1, this still works as expected and only UI strings from non-preview UI declarations are extracted and processed. Afaik, there is no setting for this in Xcode 15.1 and up. Anyone knows any other solution to avoid our catalog gets muddled with preview strings? I've already been reporting this via the Feedback hub since 15.1, but have had 0 responses from Apple on this.
Posted
by GeertB.
Last updated
.
Post not yet marked as solved
1 Replies
445 Views
For quite a while, I have been using a somewhat simple-minded technique to provide semi-automatic localizations for strings used within a few of my apps. Here is the gist: Create an enumeration with RawValue of String that conforms to LocalizedRawRepresentable. Use this enum to associate a "key" with a string (default localization) Run a script that parses all Swift code looking for the enumerations that conform to LocalizedRawRepresentable and create/update a Localized.strings file. There were some minor issues, as it isn't easy to parse a complex Swift set of sources, but it got the job done. Simple example: enum L: String, LocalizedRawRepresentable { case fileNotFound = "File not found" } // [ ... ] if !FileManager.default.fileExists(at path: String) { print(L.fileNotFound.localized) } Well, we now have Xcode 15, and we have some new features: Macros - these things can parse Swift sources with excruciating detail A new ***** called String Catalogs Xcode supports these String Catalogs by automatically detecting localizations and creating, updating, and deleting entries into Strings Catalog automatically. So, it was time to update my simplistic LocalizedRawRepresentable and update it to support the String Catalogs! So, with my contrived example above, I spent quite a lot of time reading up and experimenting with the new Swift macros and created a macro that will make localizations much easier (so I thought...): @LocalizedStrings() enum L { private enum Strings: String { case fileNotFound = "File not found" } } The macro takes this modified enumeration and expands it to the following code: @LocalizedStrings() enum L { private enum Strings: String { case fileNotFound = "File not found" } static let fileNotFound = NSLocalizedString("fileNotFound", tableName: nil, bundle: .main, value: "File not found") } extension L: LocalizedStrings { } What I expected: Xcode would pick up the NSLocalizedStrings() generated code, and insert it into the strings catalog, and all of my work is done... no scripts needed! What I got... Xcode did not detect the generated code, and nothing was added, modified, or deleted from the strings catalog. So, I have a few questions: Is my code deficient in some way? Is there something I need to add to my generated code that would let Xcode know there are localizations to be detected? Is this an intentional limitation of Xcode's auto-detection of localizations for string catalogs to ignore generated code in its detection? (I'd hate to think I went through all this work for Xcode to simply ignore what I've done...!) Is this an accidental omission of Xcode that may be "fixed" in a future release? Right now, I can use the expanded macro to cut/paste the localization keys and values into the strings catalog, but I hoped that Swift macros plus Xcode auto-detection of localizations would have made this process nearly automatic. Does anybody have any suggestions?
Posted
by lar3ry.
Last updated
.
Post marked as solved
2 Replies
204 Views
How do I switch off the json view of the project string localization. I've no idea what switched it on in the first place but I want to return to the comfortable string catalogue view.
Posted
by Alanrick.
Last updated
.
Post marked as solved
6 Replies
2.9k Views
I tried to build LocalizedKeyString using String's new Initializer. String(localized: "hello",locale: locale) When I change the language setting of the device, everything works as expected. However, when I try to get the string in a specific language using the specified Locale, I can only ever get the string in .current. String(localized: "hello",locale: Locale(identifier: "zh-cn"))     func getString(locale:Locale) -> String{          String(localized: "hello",locale: locale)     } If you change the display language of the project (or the language setting of the device), the text in Text is always displayed correctly. Text(getString(locale:.current)) However, the code in onAppear print(getString(locale:Locale(identifier: "zh-cn"))) It only displays the same content as Text, but not the specified Chinese. Is it my fault that the new Initializer The understanding is not correct, or the bug of String init(localized keyAndValue: String.LocalizationValue, table: String? = nil, bundle: Bundle? = nil, locale: Locale = .current, comment: StaticString? = nil) FB number: FB9675845
Posted
by Fat Xu.
Last updated
.
Post not yet marked as solved
0 Replies
266 Views
Lets say I got two preferred device languages( english first,italian second). I got a PKAddPassButton, which label gets the english localization on first install, but if I change the device language to Italian and relaunch the application, the buttons label has the english translation despite changing the first preffered device language to italian. I need to re install the application to get the italian string on the button. Is there anything I may be doing wrong?
Posted
by donMike.
Last updated
.
Post marked as solved
1 Replies
269 Views
Hello, I have an app which is available only for some countries, including France. But people living in Monaco, needs to cross country border, to be able to install. Is it possible? I was pretty sure, Monaco is included in France (as AppStore country settings), but I have no way to check this. Same for San Marino - if Italy is enabled, San Marino citizens should be able to install without leaving their country?
Posted Last updated
.
Post not yet marked as solved
3 Replies
439 Views
My app have different app names for en-US, Ja-jp and en-CA. CFBundleDisplayName is not getting localized for en-CA while it's working perfectly for other regional english such as en-GB,en-NZ. appName was working fine with iOS 15.4. I notice this issue only with ios16+.
Posted
by sandhyag.
Last updated
.
Post not yet marked as solved
2 Replies
392 Views
I'm using Xcode 15.2 and have migrated my (macOS) project to use an xcstrings file a while back. Now when I check the xcstrings file, all items are marked as "stale". When I add new localized strings in code, they don't show up in the xcstrings file. The xcstrings file is built correctly (into .lproj/Localizable.strings) when building. Where can I check which source files are checked to update xcstrings status? "xcstringstool" appears to have a "sync" feature which reads "stringsdata" files, but there is no information in the xcstringstool help on where the stringsdata files come from. If I create a new project I can see a "stringsdata" file being generated for each source file in the intermediate build products folder.
Posted
by Aderstedt.
Last updated
.
Post not yet marked as solved
0 Replies
222 Views
Hi, There is 2 language selections for my app. One (German) is set as the primary, english secondary language. In app store connect there are correctly 2 languages listed. Now after publishing my app, I only see English. It should be English+1 (where German is also listed) or German+1 (where English is also listed). Why is it not recognized that I have 2 languages enabled?
Posted
by julia2024.
Last updated
.
Post not yet marked as solved
3 Replies
486 Views
Hello. I have a strange issue with localized text. On some device (iPhone X with iOS 15.2.1 and iPhone 14 Pro with iOS 16.7.2) the localized isn't loaded and the UILabel is empty. In all the others UILabel in the view the localized text is correctly showed. It works perfectly on iPhone 8 with iOS 16.4.1, iPhone 8 with iOS 16.7 iPhone 12 with iOS 17.3, and also on iPhone 14 Pro 17.2 Simulator. Below the text from the localizable file: "m_alert_message" = "E' disponibile nello store la nuova App CAME Access. Vuoi iniziare la procedura per trasferire i dati di impianto nella nuova App?"; and how set the text property of the UILabel: messageLabel.text = NSLocalizedString("m_alert_message", comment: "") messageLabel.lineBreakMode = .byWordWrapping messageLabel.textAlignment = .center messageLabel.numberOfLines = 0 messageLabel.font = UIFont(name: XipAppearance.fontName, size: XipAppearance.fontSizeText) containerView.addSubview(messageLabel) Another strange thing is all other texts in all other views are correctly loaded and showed. Does anyone have any idea what the problem might be?
Posted
by Lagmac.
Last updated
.
Post not yet marked as solved
3 Replies
357 Views
I have an localized iOS App from which I want to obtain the device language (not the app language). The following sample app is localized in English and German. The current app language is German. Here I want to obtain english, since that's the device language (see next screenshot). Device Language Settings: App Language Settings: (shouldn't be considered for obtaining device language) Is there any API I could use to retrieve the device language? To obtain the device language is a product management requirement to derive next steps in the app localization process. Code of sample App: struct ContentView: View { var body: some View { Form { Text("Hello, world") Text("Locale.preferredLanguages:\n\(Locale.preferredLanguages.joined(separator: ", "))") Text("Locale.current:\n\(Locale.current.language.languageCode?.identifier ?? "")") } } } Note: I have asked this question on Stack Overflow too (see here)
Posted
by finebel.
Last updated
.
Post not yet marked as solved
0 Replies
229 Views
I have now finished my app I am learning with for different translations in different localizations and have placed the strings in the StringCatalog. I still have one question about the localization: In my project info I have added the item Localization and added the value German. So far I have told the AppStore that the app language is German. Can I delete this localization item in the info now? Or what does this entry do (see screenshot)? Due to the different languages in the StringCatalog, I now have the languages of the StringCatalog in the project settings under Localizations. This is always followed by Resources 0 Files Localized. What is this all about?
Posted
by Menslo.
Last updated
.
Post not yet marked as solved
4 Replies
2.4k Views
I am working on an app that pulls data from weatherKit, including the conditionCode property, the content of which is displayed to the user. I wish to localize the data pulled from weatherKit but when pulling data from: weatherkit.apple.com/api/v1/weather/de/{latitude}/{longitude} The conditionCode and other strings is in english. Same is true if the language parameter is set to es, ja or something else. Am I doing something wrong or is localization yet to be supported in weatherKit? I can't find any documentation on this.
Posted Last updated
.
Post not yet marked as solved
0 Replies
199 Views
Hello everyone ! I currently experience an issue with the language of our website banners. Despite having translations set in Localizable Information for titles in English, French, German and Italian, the banners aren't adapting to the user's chosen language. The title always displays in French, while subtitle ("Open in the app") remains in English, irrespective of the user's language preference. Would anyone know how can I make sure that our banners dynamically translate according to the user's language choice? Is there a setting somewhere in the apple product page that I'm missing? Thanks
Posted
by madalinaz.
Last updated
.
Post not yet marked as solved
1 Replies
462 Views
I use String Catalog to localize my app (built in English) to Japanese. The app works fine and supports both languages. I have tested on TestFlight, and the live version download from App Store also supports 2 languages. But the display on App Store only indicates Japanese. I have no idea why the number for localized files show 0 for both English and Japanese. The Localization of Japanese works fine. How to fix this?
Posted
by Boonyawat.
Last updated
.
Post not yet marked as solved
2 Replies
302 Views
Localization on 15.0.1 version of Xcode has issue with search filter. It clears the search text on language change. This is such a big hassle while searching and updating the new language values, Need to copy and paste id every time when have to change the value on each of the language.
Posted
by pareshios.
Last updated
.
Post not yet marked as solved
1 Replies
387 Views
I implemented multiple languages through Localizable.strings in the visionOS App. Now I want to test whether multiple languages can work properly, so I want to change the system language in the settings before testing, but I can't find the relevant page in the settings. What should I do?
Posted
by lijiaxu.
Last updated
.
Post not yet marked as solved
2 Replies
745 Views
Is it possible to use a string catalog to localize a settings bundle? Currently, to localize a Settings.bundle, we need to create a folder for each language with a single strings file inside. For example: Settings.bundle en.lproj > Root.strings fr.lproj > Root.strings de.lproj > Root.strings ... Any way to convert that to a string catalog? Thank you
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
2 Replies
450 Views
Hello. I have an app in the app store that I have localized into several languages. But the list of languages that the app supports in the App Store lacks English, which is the main language (and the language I developed the app in). I'm localizing the text by using String with a "localized" key and a defaultValue (in English). I also created a localization string catalog where I added added the values for each key on each language. On Xcode (15.0.1), in the app file, info, localization section I see that all languages are there with green checkmarks, except English which is at the top and is the default language. However, when I build, archive and send the bundle to AppStoreConnect, the Localizations in the Store Information section for the bundle does not include English, and so on the AppStore it looks like the app supports all of the additional languages but it does not list English. I can't figure out exactly what I'm missing. Can anyone help?
Posted
by marcbits.
Last updated
.
Post not yet marked as solved
3 Replies
440 Views
I'm trying to display an Int in Hebrew. so for example 123 should display אבג 1 = א 2 = ב 3 = ג I have tried specifying the locale based on a the answer to a different post of mine where the solution was to specify the numbering system in the locale Locale(identifier: "he-IL@numbers=hebr") print(123.formatted(.number.locale(Locale(identifier: "en@numbers=hebr")))) // Output: 123 When setting the same locale for dates it formats properly with Hebrew numbers. However if I do Arabic instead of Hebrew the numbers display properly in arabic the result for this is `` print(123.formatted(.number.locale(Locale(identifier: "en@numbers=Arab")))) // Output: ١٢٣ Below is the code I've tried running in a playground: This is the code I ran in the playground
Posted
by Timapp.
Last updated
.