Localization

RSS for tag

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

Posts under Localization tag

122 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Localizer hint for object attributes
When using storyboards, string catalogs automatically grab translation comments from the "Localizer Hint" attribute of the objects in the storyboard. The problem is that we can only specify a single comment per object. What if we need to specify a specific comment for some of the attributes of the object? For example, I often need to provide a specific comment to each segment title of segmented control objects. Currently, I'm doing that by setting the managed property of each string to "Manual" and setting the comment directly from the string catalog. There is a better way to handle these cases?
0
0
379
Oct ’23
How to identify Application language preference programatically
In the mac general setting, we can provide the language preference for an individual application like in the image below, I have provided for TextEdit app. Now based on the system preferred languages, TextEdit will have a default language. However if I explicitly set the language for TextEdit (arabic in my example), then the application will use that language. I wanted to identify in my program the language that an app is currently running in. I have tried the below code, but it always return 'en', even after my preference is set to 'Arabic'. let u = URL(fileURLWithPath: "/System/Applications/TextEdit.app") let b = Bundle(url: u)! let textedit_preference = b.preferredLocalizations print(textedit_preference) //["en"] How can I identify what language is being set by the user for an individual application? I have followed this link but it does not contain this information.
3
1
836
Nov ’23
NSDateFormatter ignores user's preferred date format
NSString* fmt = [NSDateFormatter dateFormatFromTemplate: @"yyyy-MM-dd HH:mm:ss" options: 0 locale: [NSLocale currentLocale]]; My understanding is that this should rewrite the format string to something that reflects the users current settings. When I run it, it does seem to reflect the "24-Hour Time" setting under General -> Date & Time. But it doesn't reflect the "Date Format" setting under General -> Language & Region. It seems that the date format is always the default for the region set in General -> Language & Region -> Region. It also seems to insert an unexpected comma. Specifically: Region=US, fmt="MM/dd/yyyy, h:mm:ss a" Region=UK, fmt="dd/MM/yyyy, h:mm:ss a" irrespective of the "Date Format" setting. What's going on?
4
1
414
Nov ’23
Dynamic Localization in iOS
I have the following requirement for my project: The app localization is currently based on static string JSON files. However, I would like to dynamically update strings upon an API call. Is it possible to update the resource files mentioned above after receiving a response from the API? If not, can I create a custom bundle to store new translations? Additionally, where should I create the custom bundle, specifying the path or location?
0
0
519
Nov ’23
String(localized:) return \' as thousands separator
Just found something weird with the String(localized:) method. Let's say that I have a "%lld apples" sentence inside a string catalog. If I call String(localized:"\(1000) apples") when on the device settings the number format is "1'234'567.89" and the device language is English, then the following string is returned: 1\'000 apples Any idea why the ' character has a backslash? It's a bug or I miss something? Thank you
1
0
476
Nov ’23
XCode 15 Localized strings with prefix operator function issue.
I have currently migrated to String catalogs. I have a prefix operator function like below to set a localized string and its working fine. prefix operator && prefix func &&(key: String) -> String { NSLocalizedString(key, comment: "") } Usage: let sampleText = &&"alpha.beta.gamma" label.setText(sampleText) But with XCode 15, strings from the code are not added automatically to the catalog file. But if I declare like below in the code, its working as expected. let text = NSLocalizedString("Hello world", comment: "") label.setText(sampleText) Thought and insights will be much appreciated.
2
0
526
Nov ’23
Color extension for positive/negative recognized color
Hey there! 👋🏻 I'm currently localizing my app and came across the interesting fact that in China (I'm not aware of other countries) the color red is associated with something positive, whereas in Germany (where I come from) the color green evokes a positive association. I then tried out whether this is taken into account in Apple's native apps. For example, in the Stocks app, a price gain with German localization is shown in green, whereas a price gain with Chinese localization is shown in red. Now I'm wondering whether there is a static property of the Color or UIColor class where I can retrieve a positive or negative color depending on the localization. Does anyone have experience with this? Thanks in advance! 😊
1
0
488
Nov ’23
Stop Xcode UITests running for light/dark and orientation permutations
I'm trying to run UITests just once. However, Xcode by default seems to run every permutation of light/dark color theme and device orientation and localizations. This means all UITests run 8 times (with 1 additional localization besides English). With tests that can take a couple minutes, the time to run all these adds up. Nothing in my UITest depends on the color theme, so I'd like to turn those permutations off always. The orientation and localization variations I might want sometimes but would generally also like to turn off. Questions: Can I disable any/all of these permutations? How can I get the locale string for the current run? I've tried using Locale(identifier: Locale.preferredLanguages.first!) but this just gets the device language, not the language being used on that run of the UI Test. Minimal reproducible example: Make a new SwiftUI app project in Xcode 15. Add a UI Testing Bundle target Add a localization in the general app settings, then add a string catalog called Localizable and at least one string's translation in that string catalog. Run a UITest Observe that it runs 8 times. Thanks for the help!
0
0
443
Nov ’23
App Store does not display all supported languages
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?
1
0
605
Jan ’24
Localized languages of bundle metadata in AppStoreConnect is incomplete
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?
2
0
514
Jan ’24
Xcode's implementation of Localisation is so odd
Localising my app I found the entire process quite un-swift like (i.e. unsafe and unintuitive) and was not the only one, even the great Paul Hudson also thought it a strange implementation. Following a tutorial by Andrii Halabuda (https://www.youtube.com/watch?v=_PBA20ZVk1A) relying on an Enum to reduce errors, I found that the strings needed in the "Localizable.strings" strings file could not be avoided. I have not tried localisation in SwiftUI, I see that it is different, is it easier i.e. can Plists and such be avoided ? Is there any word on deeper integration that is just more like a normal method ?
2
0
486
Nov ’23
Localization of CFBundleDisplayName in English (Canada)
I am currently facing a problem where I want to localize the application's CFBundleDisplayName in Canadian English (amongst other languages and regions). It works well for all other use cases, including Canadian French. However for Canadian English, the app's name is just displayed in the main English localization (en). To find out what is wrong, I set up a totally empty project and only localized the name - it doesn't work. I changed the type of localization from Strings file (legacy) to String catalog, same error. I summarized everything in this screenshot: I've spent so much time already and still can't figure out what is happening. Can someone maybe quickly create a new project with the two localizations like in my screenshot and report if the same problem exists for English (Canada)? TLDR: Localization of CFBundleDisplayName works for fr-CA but not for en-CA, problem exists even in minimal reproducible example (empty project with CFBundleDisplayName localization)
2
0
614
Dec ’23
Localised DMG background
Hello. We are currently creating our dmg with hdiutil and I was wondering if it would be possible to have localized resources in it. Right now, we have a single background image for every locale. Would it be possible to have different background image based on user locale, also with default background image as a backup in case we don't have users locale? The use case for this is the Quebec's Bill 96 Law 14, stating that products sold in Quebec have to be localised in Canadian french. Thank you.
0
0
426
Dec ’23
Seeing "Cannot use inflection engine" in console.
I am seeing the following log in the console in Xcode Version 15.0.1 (15A507): Cannot use inflection engine (Checking that the token is the correct type): I am able to reproduce the issue using Apple's own sample code, "Building a Localized Food-Ordering App" associated with WWDC21 Session 10109: What's New In Foundation, simply by building and running the sample code. That log message immediately appears a few times in the console when running that sample project. I'm assuming given it is happening in Apple's own sample project, that this is merely console noise and basically something out of my control.
2
0
881
Dec ’23
Serbian language fallback
We want to implement Serbian (latin) language in our app. The idea is pretty simple: if user device's preferred language is Serbian (no matter, latin or cyrillic) – we use Serbian latin, which we have in our app. The problem is that it looks like this idea is unimplementable. If we use sr_Latn as code for Serbian latin in our Info.plist, and device's preferred language is just Serbian (which is Cyrillic in iOS) – the fallback in app will be English (default language), not Serbian latin. Reverse is the same: if we implement Serbian latin as sr (just Serbian), then user select Serbian latin (sr_Latn) as device's preferred language – then app language will be English, not Serbian. In the source code published on one of the forum's answer I see that it is expected fallback (unfortunately undocumented). This code is old one, but looks like behavior still persist. Is there any way to implement one Serbian for all cases?
3
0
579
Dec ’23