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,
Localization
RSS for tagLocalization is the process of adapting and translating your app to multiple languages.
Posts under Localization tag
100 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
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
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?
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 "テスト".
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?
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"; */
I just put my app on the store for pre-order. I wanted to localize it to Spanish (don't ask me why 😅), so it should be supporting English (primary language) and Spanish. However, on the App Store, it thinks that my app only supports Spanish. How do I fix this in App Store Connect (or wherever it should be fixed)? Thank you so much for the help!
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.
In my opinion, the mail app needs a built-in translator. Very often, letters arrive in different languages and you have to take a screenshot and translate it in a third-party app.
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")}
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
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.
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.
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?
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 ?
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
XCode 16 beta1 and beta2 hangs whenever I try to open Localizable.xcstrings. The localization screen appears but afterwards XCode becomes unresponsive until I kill it. To make matters worse, upon restart the last window, Localizaton is reloaded, instantly causing a hang again (I need to be super quick as I have about half a second to try to click elsewhere like crazy). The same localization strings file works fine on XCode 15.4.
I tried to export all localizations in 15.4, empty the file, re-generate localization strings, re-import languages one by one in 16, starting with different languages (thinking maybe a weird exotic character causes the issue with one of the languages, this happened previously crashing XCode 15 until I found the offending character and replaced it with something else). But generally even after just adding a single language there is a serious slowdown - after adding the second one, XCode hangs again.
Note: the app in question has a lot of localizable strings - I had no issue creating a simple project with only a few strings. Just hoping a fix - I really wished the issue was fixed in beta2 but now I am a bit concerned that maybe it's a rare problem and might not get fixed as I saw no similar reports so far.
I'm encountering the following error while attempting to archive my app:
unable to read input file: fopen({~}/Library/Developer/Xcode/DerivedData/{project name}-gxaapsrbutxnmwderhyslgnfznrl/Build/Intermediates.noindex/ArchiveIntermediates/{project name}/IntermediateBuildFilesPath/{project name}.build/Release-iphoneos/{project name}.build.lproj/Localizable.strings, rb): No such file or directory (2) (in target '{project name}' from project '{project name}')
I've anonymized {project name} and {~} in the path for privacy reasons.
It seems like the error pertains to not finding the localizable.strings file. Prior to encountering this error, I made the following modifications:
Originally, my project used the legacy localizable.strings for localization, but I recently switched to using a string catalog.
I added 8 additional languages alongside the existing Base, English, and Korean.
I'm writing into the new Localizable.xcstrings file using some python scripts. When I open it in Xcode after pasting, all rows appear correctly.
This error occasionally occurred even when I 'run' the app, but clearing derived data and cleaning the build folder resolved it temporarily. However this error happens always when I try to 'archieve' this.
Despite copying the project due to difficulty resolving the issue within the project itself, I'm still encountering the same problem.
Below are the Build Setting and Build Phases configurations:
Build Phases > Compile Sources and Link Binary with Libraries do not include localizable.strings.
Build Settings > Localization is set to "Yes" for all.
I've tried various methods found online without success, and similar cases are scarce. Please help me resolve this issue.
I'm the developer of a third-party keyboard app, Snippety - Snippets Manager, which is designed for using snippets rather than regular typing.
One of my users has encountered a strange issue: after installing my keyboard (even when it is not actively in use), the predictive text bar starts showing suggestions in Polish. This happens despite the Polish language not being installed on the device. The issue resolves as soon as my keyboard is uninstalled from the system settings.
Interestingly, my application (including the keyboard) does not support the Polish language, nor is Polish specified anywhere in the app. The app was developed and published from macOS in English. This seems to be an iOS bug.
The only language-related configuration in my keyboard is the PrimaryLanguage key in the Info.plist file, which I set to "mul" because the keyboard is not intended for typing. I also tried setting it to "mis", but the issue persists.
The video presenting this issue on an iPhone 15 simulator running iOS 17.5:
https://www.dropbox.com/scl/fi/xjdyucxpmv1cv0mnmwzvd/prdictive-text-issue.mp4?rlkey=aphznpdti08pz8xl84ojbyxz3&dl=0
Info.plist for my keyboard:
My project settings:
Steps to reproduce:
Configure iOS to use English language only, with English keyboard
Enable predictive text feature in the system
Install Snippety keyboard
Use the regular keyboard & start typing "dzie"
Actual result:
Polish predictions appear even though the Polish language is not installed or declared by the keyboard.
Expected result:
The predictive text should present predictions based on system settings.
What is even more weird, I discovered that when I add the keyboard in system settings, it automatically installs Polish language in the system settings. I even changed PrimaryLanguage to "de" (German) in Info.plist but it still installs Polish.
See: https://www.dropbox.com/scl/fi/aiv5g4z331zwy827zj47v/incorrect-language-installed.mp4?rlkey=16v5gqmb6mj8yuyyd7jwmjnsw&dl=0
Any ideas what could be wrong?
I also created a ticket: #FB13949087
I also found a similar issue from 2018 (O_O) reported here: https://stackoverflow.com/questions/53069262/ios-adds-new-preferred-language-when-installing-my-3rd-party-keyboard
Hi
This issue is present both in previous, current, and beta versions of Xcode
When a project has localization in packages, Xcode FAILS to export localization
The reason is that when trying to export in this configuration, the compiler will try to export using macOS sdk, but if the package support only iOS of course will not find symbols for frameworks and functions that are scoped only for iOS
This behaviour is not changed when the platforms for the package includes ".macOS("99") has I've found as a suggestion online
The only way to perform this operation is to run, from CLI the following command
xcodebuild -exportLocalizations -localizationPath . -sdk iphoneos -project TranslateTest.xcodeproj -exportLanguage en
The problem is that this command will not work when one of the packages contains a macro.
The following error will return in CLI if the macro is used (if the package is only imported no error appears)
error: external macro implementation type 'MyMacroMacros.StringifyMacro' could not be found for macro 'stringify'
I've found online some suggestions from apple folks that says to replace
-sdk iphoneos
with
-destination 'platform=iOS,name=Any iOS Device’
in case your project contains a macro, but this changes nothing in the final result, the export will fail
I'm providing a zip for apple in the radar (cannot upload zip here) that contains 3 example project for the 3 cases:
A project without any packages that can extract its strings with any mode
A project with a package that can only extract its strings only by CLI
A project with multiple packages, one of which has a macro, and it can never extract its string
This problem affects any possibility to have a modularised application with localisations, macros, and packages.
Feedback FB13902424