Localization

RSS for tag

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

Localization Documentation

Posts under Localization tag

138 Posts
Sort by:
Post not yet marked as solved
0 Replies
86 Views
I was wondering why the Text View in SwiftUI is (as far as I know) the only View that accepts a LocalizedStringRessource in its init. Are there better alternatives? I know there is LocalizedStringKey, which works great with SwiftUI Views but is limited if you want to access the localised string in non-UI code. This results in the inconvenient situation of writing code like this: struct LocalizedView: View { let localizedString = LocalizedStringResource("Localize Me!") var body: some View { Text(localizedString) // Does not work // Label(localizedString, systemImage: "questionmark") // Inconvenient Label(String(localized: localizedString), systemImage: "questionmark") } } Best, Chris
Posted Last updated
.
Post not yet marked as solved
1 Replies
120 Views
Hi Folks, I've been researching how to implement a feature in my ios app that changes the app icon based on the user's location, essentially localizing the app icon. I'm aware of alternateIconName, but I'd like to avoid prompting the user to choose an icon themselves. Are there any other workarounds to achieve this? Thank you, Camron
Posted
by Camron.
Last updated
.
Post not yet marked as solved
3 Replies
111 Views
I have encountered an issue related to the usage of string catalogs in a Swift package. I created a repository for reproduction. https://github.com/atacan/DiscussionStringCatalogPackage The Readme.md file has all the details. Here is a short summary: The Package.swift file's target has resources: [.process("Resources")], and this Resources folder contains a string catalog. The catalog is correctly populated by the compiler, and German translations are added. Text view is using bundle: .module argument. However, when the scheme run options are changed to German, the UI still displays English text. Xcode throws a warning indicating that the German translation for the text is not found in the Localizable table of the bundle and it says (not loaded). Although the bundle contains translations in the Localizable.strings file. Screenshots of the issue are available in the original README file. I am looking for any insights or solutions to this problem.
Posted Last updated
.
Post not yet marked as solved
6 Replies
1.8k Views
I have added additional localizations into my iOS app. iOS is not available in those languages. So I did as it is suggested that you redirect customers to app settings view UIApplication.openSettingsURLString and there they can select another app language. Unfortunately they do not see language selection if they do not have set at least 2 Preferred languages in General -> Languages & Region. Also it does not matter what languages they have there. If my app does not support those then it still shows all localizations available. Is there somehow to force it? So it would be visible always? Since most people in my country have iPhones only in English but would like to use Apps in their native language.. Since they do not have 2 preferred languages they cant see the selection :(
Posted Last updated
.
Post not yet marked as solved
2 Replies
153 Views
I've a workspace with multiple packages, and due to the a bug in Xcode I cannot export the app localizations using the Xcode GUI tool, but I need to resort on using a command from terminal xcodebuild -exportLocalizations -localizationPath . -workspace <path_workspace> -sdk iphoneos -exportLanguage en One of my packages contains some macros, and I use them from my code without any problem, the code compile But when I try to export localizations using that command, the build fails due to "compiler plugin not loaded" So I cannot use Xcode normal exporting because Xcode bug, and cannot export by running a command due to the macro problem What should I do? It is very discouraging this situation, do you have any suggestion? I've found a similar problem
Posted
by Playrom.
Last updated
.
Post not yet marked as solved
7 Replies
689 Views
I tried to migrate to the new localized string catalogs. But after this I can't build the app anymore. The error message stated something about an "old" .string file... but I checked all directories and there are no old .string files... Anybody a hint how to go further? And this is how the directories look after migration ...
Posted Last updated
.
Post not yet marked as solved
0 Replies
104 Views
I want to make use of String Catalog for some words that show the differences between countries like the USA and Canada. For example, I added both languages to my string catalog and I would like to have: Enter your Zip Code [English] Enter your Providence [English (Canada)] If I run the app without any change in the tables, I see all values shown correctly, but when I make this 1 word change in required field, all other strings start showing their keys instead of base values that are already in English language. What is the easiest way to achieve this using String Catalogs other than copy/pasting all the values from English table to English (Canada) table? I don't want to or need to translate all the strings in the catalog since they are literally the same, all I need is having iterations for some words.
Posted Last updated
.
Post not yet marked as solved
2 Replies
115 Views
Hi, I'm parsing iOS localization files and during tests with xcode 15 i noticed new lines appear in the xcloc files with LS instead of the usual LF i was used to. Questions: is this the default behavior in xcode 15? Has this changed with this version? is this controllable by any settings? Disclaimer: not a iOS developer here, please pardon any confusions and have patience.
Posted
by JustRTFM.
Last updated
.
Post marked as solved
1 Replies
170 Views
I am using a string resource in the following way: let content = UNMutableNotificationContent() content.body = NSLocalizedString("notification_body_" + String(notificationBodyId), comment: "") And will have a number of strings defined in the strings catalog notification_body_1, notification_body_2 etc. This works fine, but the feature of strings catalogue that is automatically grepping source code for usage of strings is inserting an entry reality_check_notification_body_ that will obviously never be used & never be translated (thus showing my translated percentage at less than 100%). Xcode doesn't appear to provide a way for me to delete / ignore these automatically created string resources (delete button is disabled where available for manually created string resources). Is there some other way in code I should have referenced this resource, or some workaround to remove the string from strings catalog (no doubt if I manually remove from the backing file, it will simply be re-created). Thanks. Xcode 15.3
Posted
by jammmie.
Last updated
.
Post not yet marked as solved
0 Replies
112 Views
Hi! We added Spanish to the String Catalog. Turned out there are a lot of changes we should make to already localized text. How can we temporarily turn off / disable this language to fix all issues and then turn on Spanish support again? Thank you!
Posted
by IvannaSi.
Last updated
.
Post marked as solved
3 Replies
1.3k Views
In stringsdict it was possible to define a format separately from the translation so you could do something like "n_days" which you could pass in an integer and it would return you only "Day" or "Days" without the actual value in it. And it's work great. But now with the strings catalog it seems like the format specifier HAS to be in the value, otherwise it's not recognized. Is there now no way to pluralize anything without having the actual value inside the translation? Cannot infer format specifier for string group because no numerical specifiers were found (en: %d.n_hours)
Posted
by uniqby.
Last updated
.
Post not yet marked as solved
0 Replies
116 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
228 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
129 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.5k 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
156 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
193 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
357 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
246 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
.