Localization

RSS for tag

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

Posts under Localization tag

97 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

JSONEncoder: How to sort keys using "localizedStandardCompare"? (just like how Xcode 16 serialize a xcstrings file)
Hello, I'd like to ask a very fundamental question about JSONEncoder: how to sort keys in a specific order when encoding a dictionary to JSON text? I know there is an option called JSONEncoder.OutputFormatting.sortedKeys, but it sorts the keys only in lexicographic order. I want to sort the keys using a different comparator, such as String.localizedStandardCompare(_:), which achieves the "Finder-like" order. The reason why I ask this question is because I have a localization tool that works with String Catalog (xcstrings file, which is a JSON), but every time my tool serializes an xcstrings file, it always messes up the keys in lexicographic order (I used JSONEncoder + .sortedKeys). Meanwhile, Xcode 16 always serializes the string keys into the "Finder-like" order. As a result, my tool always generates a huge diff when manipulating the xcstrings even when making only a small modification to it. So I am wondering how Xcode 16 implements the String Catalog tool to serialize the JSON in "Finder-like" order. It would be great if JSONEncoder could do that too. Or, maybe I can use another serialization method to implement this behavior?
4
0
857
Sep ’24
String catalog and local package
Hello Apple community ! I'm facing an issue regarding xcstrings in a local package in my project. It's an iOS application with a local package containing multiple targets. The Localizable.xcstrings is located in the app target and contains keys for the app and targets of the local package (Views in the targets look for keys in the main bundle) My issue is that auto detection/extraction seems to work only for keys used inside the app bundle. It doesn't look in the package. However, if I add a Localizable.xcstrings inside a package target, it gets populated. Is this normal behaviour & is there any way to make extraction put the keys in the main bundle xcstrings instead ? I feel like it should be normal behaviour if no xcstrings is found in the package My fallback would be to set all keys in manual extraction state but it's not ideal ;) Thanks in advance for the great work Eric
1
0
635
Sep ’24
Issues with Displaying Language Tags Compliant with RFC 5646
Hello, I'm currently facing some issues with localization for the Safari extension on iOS: Issues with Language Tags: Folder names like pt-BR (Brazilian Portuguese) and pt-PT (European Portuguese) placed in the Resources/_locales/ directory are not displaying the respective languages correctly; instead, the default English is shown. Similarly, using folder names like zh-CN (Simplified Chinese) and zh-TW (Traditional Chinese) also results in default English display instead of the intended Chinese language. Conversely, when changing the folder names to pt (Portuguese general) and zh (Chinese general), the languages display correctly. Could you please provide any recommendations or tips regarding language tag settings and how to ensure they are properly recognized according to RFC 5646? Thanks for your help! Best,
5
0
1.2k
Oct ’24
String Catalog on separate Package
I'm creating a new app, following String catalogs,  But, after start creating separate packages per feature, I found that I have to start typing String(localized: "Test", bundle: .module) To not loose the functionality of auto sync with the catalog, and work with the module. Would be really great if as it is on a separated module, work automatically within the file in the module. Do someone knows if I'm missing something ? Thanks
1
0
429
Aug ’24
"Add to Apple Wallet" (PKAddPassButton) title localization to device language
Hi there! My app supports one language by default Ukrainian (uk) and does not support multiple languages. In Xcode settings "Development Language" is set to Ukrainian by default also. I have a PKAddPassButton on a ViewController and "Add to Apple Wallet" always appears in Ukrainian (Tested on real device iOS 15/16/17). Apple's "Getting Started with Apple Pay: In-App Provisioning, Verification, Security, and Wallet Extensions” document states that "The Add to Apple Wallet button adapts to the device language and the light and dark appearances, but the issuer app needs to adapt the language of the row selector text." When I change device language to French the “Add to Apple Wallet” button does not change to French. I created a fresh swift app, added PKAddPassButton the "Add to Apple Wallet" button, General -> Language & Region changed the device language to French, etc, but the "Add to Apple Wallet" button is always in English. Has anyone run into the same issue? How to adapt the "Add to Apple Wallet" button to the device system language?
2
0
1.1k
Aug ’24
Incorrect `NSLocationWhenInUseUsageDescription` is displayed from InfoPlist.xcstrings when default localization key/value has a `state` of `new`
en.lproj/InfoPlist.strings ja.lproj/InfoPlist.strings (I resolved this issue but I still consider it a bug in Xcode. Hopefully any other poor soul that encounters it will find this post.) Summary When App default localization is e.g. Japanese Secondary localization is e.g. English InfoPlist.xcstrings is added to the target NSLocationWhenInUseUsageDescription is added in Japanese to Info.plist (within target build settings). NSLocationWhenInUseUsageDescription is localized to English CLLocationManager().requestWhenInUseAuthorization() is called Then If device language is English: NSLocationWhenInUseUsageDescription is displayed in English on the location permission system dialog (correct behavior). If device language is Japanese: NSLocationWhenInUseUsageDescription is displayed in English on the location permission system dialog (incorrect behavior). Expected behavior If device language is Japanese: NSLocationWhenInUseUsageDescription should be displayed in Japanese on the location permission system dialog. Root cause The json representation of InfoPlist.xcstrings is the following after following the above procedure: { "sourceLanguage" : "ja", "strings" : { "NSLocationWhenInUseUsageDescription" : { "comment" : "Privacy - Location When In Use Usage Description", "extractionState" : "extracted_with_value", "localizations" : { "en" : { "stringUnit" : { "state" : "translated", "value" : "test" } }, "ja" : { "stringUnit" : { "state" : "new", "value" : "テスト" } } } } }, "version" : "1.0" } After building, Xcode creates the key NSLocationWhenInUseUsageDescription.ja.stringUnit.state with the value new, and the value as テスト (the automatically extracted value from Info.plist). At runtime, iOS ignores ja.stringUnit.value and falls back to en.stringUnit.value when: NSLocationWhenInUseUsageDescription.localizations.ja.stringUnit.state == "new" NSLocationWhenInUseUsageDescription.extractionState == "extracted_with_value" Additionally, Xcode's "String Catalog" interface for xcstrings files does not show the new state value in the interface and does not allow ja.stringUnit.value to be modified. Fixes/Workarounds Option 1 Open InfoPlist.xcstrings in string catalog mode. Right click the entry in the source language. Click "Mark as Reviewed". Option 2 Open InfoPlist.xcstrings in source mode. Change all {sourceLanguage}.stringUnit.state values from new to translated. Option 3 Remove NSLocationWhenInUseUsageDescription key from Info.plist or build settings. Add NSLocationWhenInUseUsageDescription key manually to InfoPlist.xcstrings. Fill in values for source language and other languages. Note: {key}.extractionState for this case will be manual instead of extracted_with_value. Option 4 Use older/deprecated InfoPlist.strings files instead of .xcstrings. InfoPlist.xcstrings after fix { "sourceLanguage" : "ja", "strings" : { "NSLocationWhenInUseUsageDescription" : { "comment" : "Privacy - Location When In Use Usage Description", "extractionState" : "extracted_with_value", "localizations" : { "en" : { "stringUnit" : { "state" : "translated", "value" : "test" } }, "ja" : { "stringUnit" : { "state" : "translated", "value" : "テスト" } } } } }, "version" : "1.0" } Reproduceable Environment Xcode 15.4 / iOS 17.5 Xcode 16 beta 5 / iOS 18 Simulator Device Screenshot of bug "test" should be "テスト".
1
0
800
Aug ’24
Localise - Seperate screenshot for my primary location?
Hi Guys, I want to localise my app store product page. I want to have a default set of images for all product pages and for my primary location (Australia), I want my primary image to be different. I want to show that it is Australian-made. by default your primary location becomes your default for all other images and I don't want the same screenshot in all other stores (US, UK,JPN etc) Any ideas?
0
0
405
Aug ’24
Localization of App Using String Catalogs - Storyboard
Hi everyone! I want to localize my swift application, which uses Storyboard, using String Catalogs. I have watched several tutorial videos about localization, however, it uses SwiftUI. I have tried localizing my storyboard through .string and migrating it to String Catalogs and it worked. (Example codes are attached below) But in the tutorials, String Catalogs extraction works when you build the project. But if you are using storyboard, I think it is not possible? or are there any other ways to extract the strings from storyboard using string catalogs directly and not using .strings and migration? This also makes me wonder if the Vary by Plural will work with the method that I did. Thank you so much in advance! Have a nice day ahead! Sample Codes from .strings (storyboard): /* Class = "UITextField"; placeholder = "Enter Password"; ObjectID = "08D-xr-4ke"; */ "08D-xr-4ke.placeholder" = "Enter Password"; /* Class = "UIButton"; configuration.title = "Login"; ObjectID = "2gQ-cX-5nH"; */ "2gQ-cX-5nH.configuration.title" = "Login"; Migrating it to String Catalogs: key : 08D-xr-4ke.placeholder English(en): Enter Password comment: /* Class = "UIButton"; configuration.title = "Login"; ObjectID = "2gQ-cX-5nH"; */
1
1
886
Aug ’24
Localization Glitch
I've mentioned this before but I don't think it's getting seen by a department that can deal with it. I think it may be a Connect issue. I have localizations in multiple languages. They are all created the same way. In that the images are the same as the default language. I tried to rely on icons rather than text wherever possible to keep language from being a limiting factor. Since releasing the app, I've tried a few ways to advertise it. One being ASA (Apple Search Ads) Basic. It accepts all my localizations except for Brazil. Even accepts Portugal. When I email ASA tech support, I get generic sounding replies that are some variation of "add localization for Brazil and then the ads will start running". They do seem to acknowledge the text localization is there but seem to believe the images are not. This despite sending a screen cap. They do not attempt to explain why Brazil needs special treatment from all other localizations or why this isn't indicated in App Store Connect. I assume they are saying that despite the images already being there, I need to copy them to the Brazil localization anyway for some unknown reason. This article indicates Brazil is a new addition to ASA for this year. This makes me suspect it may have a glitch. I intended to only advertise in a few markets to start. Which didn't include Brazil initially. But ASA Basic isn't spending at all. On second attempt, it did net five downloads the first day and then hasn't had once since. This made me suspect one glitch may be causing another. Or maybe it is unrelated and advertising costs are just insane. Still, I think it's a possible glitch worth investigating.
1
0
525
Nov ’24
AppIntent Title Localization
Does anyone know how to localize the title of the shortcut? I tried to create a localizable file and then do a french translation. However, when I reference it as my shortcut title and change my simulator's language to the translated language (in this case french) it still displays the title in the english translation. for example: my Localizable.strings file says in english: "shortcutTitle" = "Hello!"; in french: "shortcutTitle" = "Bonjour!"; and then my AppIntent says: static var title: LocalizedStringResource{return LocalizedStringResource("shortcutTitle")}
1
0
816
Jul ’24
Disable automatic InfoPlist.xcstrings generation
Hi all, I am trying to localise the purpose strings in my Info.plist file, for that I am using the InfoPlist.xcstrings file. In my app I have multiple targets, each with a different display name, the problem that I am facing is that when the InfoPlist.xcstrings file is automatically updated in each build the CFBundleDisplayName is always added to the file which forces me to have just one name for every target. So, I would like to know how others approach this problem and how can I resolve my situation. The ideal solution was that there was a way for me to disable this automatic generation (or at least trigger it by hand) once I have added all the purpose strings that I want to localise in multiple languages. If not, having one InfoPlist.xcstrings per target will also so it, although it will be a little harder to maintain. AFAIK, there's no documentation on the InfoPlist.xcstrings generation, so any help will be very much appreciated. Thank you all in advance
2
0
1k
Jul ’24
xcodebuild -exportLocalizations does not respect build scheme or configuration
Description of Problem We are exporting strings for localization using the command line tool xcodebuild -exportLocalizations. However, Xcode does not respect the scheme or configuration that we specify. It always builds the Debug configuration. This results in extraneous or incorrect strings being exported, e.g. strings from SwiftUI previews. Note: Exporting strings from within the Xcode IDE respects the selected scheme and configuration. However, exporting from the command line does not. Our real app’s Xcode project cannot export strings from within the Xcode IDE at all, as Xcode always attempts to build our iOS project using the macOS SDK, which obviously fails. So we must use the command line export. Also, a command line export is required for CI/CD pipelines. Sample Code ContentView.swift import SwiftUI struct ContentView: View { var body: some View { VStack { Text("Always") #if DEBUG Text("Debug-Explicit") Text("Debug-Implicit") #else Text("Release-Explicit") Text("Release-Implicit") #endif } .padding() } } // MARK: - Previews #if DEBUG struct ContentView_Previews: PreviewProvider { static var previews: some View { VStack { Text("Preview only string") ContentView() } } } #endif Localizable.strings /* Appears in all builds */ "Always" = "Appears in all builds"; /* Appears in debug builds only */ "Debug-Explicit" = "Appears in strings file but only used in Debug builds"; /* Appears in release builds only */ "Release-Explicit" = "Appears in strings file but only used in Release builds"; Steps to Reproduce Clone this project into a directory on your Mac, but do not open it in Xcode. git clone https://dev.azure.com/slardieri/ReproRepos/_git/ExportRepro Open a Terminal window and cd into that directory. Run the following command to export strings for localization: xcodebuild -exportLocalizations -sdk "iphoneos" -exportLanguage "en" -localizationPath "./ExportRepro Localizations" -project "./ExportRepro.xcodeproj" -scheme "ExportRepro Release" -configuration "Release" Open the generated en.xliff file and observe which strings were exported. open "./ExportRepro Localizations/en.xcloc/Localized Contents/en.xliff" Expected Behavior Based on the Release configuration specified in the command, you should see both the Release-Explicit and Release-Implicit strings, but not the Debug-Implicit or Preview only string. Actual Behavior What you actually get are the Debug-Explicit, Debug-Implicit, and Preview only strings, but not Release-Implicit.
3
1
679
Jul ’24
QLPreviewController's PencilKit sub component doesn't get mirrored on RTL Languages in iOS18b3
QLPreviewController's PencilKit doesn't get mirrored when used with a RTL language in iOS18b3. Moreover, the sub-menu of the actions is not translated and is shown in English. Steps to reproduce: Set an app with QLPreviewController and set its app language to Hebrew (or any other RTL language) Run the app Tap the Markup button on bottom-left side. Look on the PencilKit element. Tap the + button to show the annotation actions. Look on the annotation actions menu. Current: The Pencil Kit element is not mirrored when app language is RTL Language and the sub-menu actions are shown in English. Expected: The Pencil Kit element is mirrored when app language is RTL Language and the sub-menu actions are shown in the RTL Language. Submitted Feedback: FB14452847 Notes: This wasn't reproducible in iOS 17.5.1 The top bar buttons are mirrored as expected with a RTL language.
5
0
1k
Aug ’24
LOCALIZED_STRING_MACRO_NAMES for Swift package targets?
I have a custom localisation function in my project that enforces the inclusion of the bundle parameter (specifically so that Swift packages are forced to include the Bundle.module value). While migrating to String Catalogs, I noticed that my custom localisation function wasn't being recognised by the automatic extraction that the Swift compiler is doing, but only in my Swift package targets. Is there a way to set something like LOCALIZED_STRING_MACRO_NAMES in Swift Packages?
1
0
785
Jul ’24
Localization for multiple targets
I have one project where I have XYZ scheme and target. I have Localizable.string under XYZ target for localization. I want to create a ABC target (duplicate of XYZ) and set custom language support for it. Let's say I have english, french and german for XYZ, I want hindi, japanese and chinese for ABC. I did the below steps I went to Manage scheme and duplicated the XYZ (duplicate scheme = ABC). I added new localization file only for ABC (LocalizationForABC.string) and made sure those reflect in File Inspector -> Target (only ABC selected) and also checked in Build Phases -> Copy Bundle Resources (LocalizationABC exists). When I run the ABC target under let's say french, it works fine but when I build the project ABC, and remove french from XYZ, ABC is broken and it only runs in english. Am I missing something here ?
3
0
906
Jul ’24
Automatic Grammar Agreement with formatted number: use integer value to switch categories
Hello, I want to use Automatic Grammar Agreement to localise a string in my app, let say "three remaining activities". The string "three" is obtained by using a NumberFormatter with a numberStyle set to .spellOut (so I'm not using an Integer) var formatter: NumberFormatter = NumberFormatter() formatter.numberStyle = .spellOut let formattedCount: String = numberFormatter.string(from: count as NSNumber)! Text("key_with_string_\(formattedCount)") In my string catalog, I have translated the key key_with_string_%@ like this ^[%@ remaining activity](inflect: true), but it does not work. I've tried to add the integer value used by the number formatter in the key key_with_string_%@_%lld but it does not work. Should Automatic Grammar Agreement work normally just by using the formatted string provided by the NumberFormatter? If not, is there a way to specify to use a secondary variable (my count integer) to switch between different categories like one and other automatically? Thanks ! Axel
1
0
765
Jun ’24