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?
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
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?
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?
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.
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?
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+.
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?
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)
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?
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
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.
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?
Hi everyone,
I'm currently working on a React Native app and need assistance with localization. Specifically, I've added an InfoPlist.strings file for NSUserTrackingUsageDescription and created language-specific files for each supported language.
However, when I try to build the app in Xcode (version 15.0.1), I encounter the following error:
error: unable to open dependencies file (/Users/myname/Library/Developer/Xcode/DerivedData/myproject-bxfjslkrewxnfcgmeelilvixy/Build/Intermediates.noindex/myproject.build/Debug-iphonesimulator/myproject.build/DerivedSources/Users/myname/projects/project-folder/ios/en.lproj/InfoPlist.strings.d) (in target 'myproject' from project 'myproject')
Any insights or solutions would be greatly appreciated. Thank you!
Hey everyone,
I have translated my app using the newest String Catalog feature but im wondering how can I translate the strings from the Target -> Info tab.
I have read the string catalog documentation and searched on the internet but I can't find a recent post talking about it. I have found methods related to the info.plist file but afaik that would be legacy documentation as I can't even find a info.plist file in my project anymore. Also tried to look for posts talking about it here, but maybe I'm not using the right words as I couldn't find anything.
I only found this article that mentions translating the strings from info but still couldn't see how to do it: https://developer.apple.com/documentation/bundleresources/information_property_list/managing_your_app_s_information_property_list#3375316
So if someone could help me out, it would be very appreciated, thanks.
EDIT: I just followed the "creating a infoplist.strings" way and it worked, but im still wondering if there is a newer way to do it. I tried to just add a manual string in the string catalog using "NSContactsUsageDescription" as key but it didn't work
Hello,
I migrated a project to use String Catalogs (Localizable.xcstrings) instead of Localized.strings and Localized.stringsdict files.
So far so good, but since I use a lot localized strings in my project, there are quite some localizations used more than once in different contexts and thus with different comments.
For example:
Source file 1:
String(localized: "Something", comment: "Button title for context1")
Source file 2:
String(localized: "Something", comment: "Column title for context2")
This results to a Localized.xcstrings file with this content:
{
"sourceLanguage" : "en",
"strings" : {
"Something" : {
"comment" : "Column title for context2\nButton title for context1"
}
},
"version" : "1.0"
}
The main problem with this is, that the order of the concatenated comment changes randomly during each build. After the next Xcode build (without any code changes), the same Localized.xcstrings file might look like this:
{
"sourceLanguage" : "en",
"strings" : {
"Something" : {
"comment" : "Button title for context1\nColumn title for context2"
}
},
"version" : "1.0"
}
This leads to false positives when trying to commit changes to a git repository, which is quite annoying.
Am I the only one, having issues with comments in String Catalogs and git?
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?
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.
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.
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)
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 ?