Localization

RSS for tag

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

Localization Documentation

Posts under Localization tag

135 Posts
Sort by:
Post not yet marked as solved
2 Replies
532 Views
I've noticed that genstrings does not include String(localized:) in the .strings exports. I created a feedback but was wondering if anyone had any work arounds. I know there is Export Localizations, but that creates a .xliff which itself has other issues like changing \n and & to html encoded characters. This then also seems to mess up directory structure if you import them back as it puts them into the root folder and not into my localization folders. This would be fine if I wanted to do everything manually but I'm looking to automate this during the CI phase.
Posted
by
Bot
Post not yet marked as solved
1 Replies
282 Views
I am currently facing a problem with DateIntevalFormatter. When using the formatter with dateStyle = .long and timeStyle = .none the string output for some locales is not in the expected formatting. While the output for locales like en_US, de_de or fr_fr is as expected, locales like zh_Hans, ja and ko is not consistent with the dateStyle = .long of a DateFormatter. Using the dateTemplate/setLocalizedDateFormatFromTemplate() with template MMMMddyyyy seems to provide a consistent output. Is that maybe a bug in DateIntervalFormatter? Here some exemplary output of the below Playground code: It seems that the forum is not accepting some of the Chinese, Korean or Japanese characters, therefore you can only find the actual output of below code as attachment. Code output import UIKit func printDate(starteDate: Date, endDate: Date, locale: Locale) { let interval = DateIntervalFormatter() interval.locale = locale interval.dateTemplate = "MMMMddyyyy" let formatter = DateFormatter() formatter.locale = locale formatter.setLocalizedDateFormatFromTemplate("MMMMddyyyy") print("Locale: \(locale), template: MMMMddyyyy") print("Interval = \(interval.string(from: starteDate, to: endDate))") print("Format = \(formatter.string(from: starteDate))") print("Locale: \(locale), dateStyle: long") interval.dateStyle = .long interval.timeStyle = .none formatter.dateStyle = .long formatter.timeStyle = .none print("Interval = \(interval.string(from: starteDate, to: endDate))") print("Format = \(formatter.string(from: starteDate))") } let date1 = DateComponents(calendar: Calendar(identifier: Calendar.Identifier.gregorian), timeZone: TimeZone(abbreviation: "UTC"), year: 2019, month: 12, day: 20).date let date2 = DateComponents(calendar: Calendar(identifier: Calendar.Identifier.gregorian), timeZone: TimeZone(abbreviation: "UTC"), year: 2019, month: 12, day: 22).date printDate(starteDate: date1!, endDate: date2!, locale: Locale(identifier: "en_US")) printDate(starteDate: date1!, endDate: date2!, locale: Locale(identifier: "de_de")) printDate(starteDate: date1!, endDate: date2!, locale: Locale(identifier: "zh-Hans")) printDate(starteDate: date1!, endDate: date2!, locale: Locale(identifier: "ko")) printDate(starteDate: date1!, endDate: date2!, locale: Locale(identifier: "ja"))
Posted
by
Post not yet marked as solved
4 Replies
791 Views
Running on a Core i9 MacBook Pro with macOS 13.4 (22F66) and the Xcode 15 beta. Running "Export Localizations" seems to work fine with smaller projects, but in my larger project, it's not working unless I do a "Clean" first. The way my project is set up is that the main project depends on a few dynamic frameworks built from other Xcode projects which are incorporated into the main project and set as dependencies. What happens is that I'm getting the error "Unable to build project for localization string extraction. See the build logs for failure description." In the logs, I see that the Link (x86_64) step succeeds, but the Link (arm64) step fails, with a Could not find or use auto-linked framework 'MyFramework' message for each framework dependency that's in another Xcode project. This would suggest that the dependencies are being built only for x86_64. If I clean the project, the "Export Localizations" will then succeed, but if I do a regular build again, "Export Localizations" goes back to being broken. What I think is happening is that the "Export Localizations" workflow is using the same binaries as Debug builds, and leveraging any existing Debug builds that happen to exist instead of rebuilding them, but it's also trying to build for all supported architectures whereas a Debug build usually only builds the current one. This, of course, causes a failure to link to dependent libraries/frameworks, since they don't have binaries for the non-active architecture. Is there any way to turn off building for all architectures for the "Export Localizations" workflow? I don't think it's necessary just for localizations TBH.
Posted
by
Post not yet marked as solved
1 Replies
1.2k Views
Migrating from localizable.strings to string catalog is simple. After migrating the state of 55% are checked okay, 45% are marked with state "new". Why happens this? Reviewing the new strings and marking as "reviewed" would now mean to change each of the 60 "new" marked rows x 4 languages manually - a lot of work. Is there a way to group change the states of all strings?
Posted
by
Post not yet marked as solved
2 Replies
654 Views
When running xcodebuild to programmatically export or import xcloc resources, I receive an internal error and do not know how to proceed. Note: Export and import localizations within Xcode does complete successfully. Is there a way to see the exact xcodebuild command run by Xcode? For example: xcodebuild -exportLocalizations -project ./MyProject.xcodeproj -localizationPath destination -exportLanguage da output: xcodebuild appears to successfully build my project, and then fails once "Copying source language files". There are several suspicious entries in the output of all the detected strings. For example: ... ... 0.01ms /pathtomyproject/File.swift:19:21 setter cancellable 0.01ms /pathtomyproject/File.swift:19:21 _modify accessor cancellable 0.10ms /pathtomyproject/File.swift:21:5 initializer init(sceneFlow:) 5.49ms /pathtomyproject/File.swift:25:10 instance method viewControllerForOnboardScene() 0.00ms /pathtomyproject/File.swift:15:13 deinitializer deinit 0.86ms <invalid loc> initializer init(rawValue:) 0.12ms <invalid loc> getter rawValue 0.02ms <invalid loc> static method __derived_enum_equals(_:_:) 0.52ms <invalid loc> instance method hash(into:) 0.04ms <invalid loc> getter hashValue ... ... 2023-06-12 13:52:36 Extracting strings from localizable files 2023-06-12 13:52:36 Copying source language files 2023-06-12 13:52:36.804 xcodebuild[22356:3140982] -[NSTaggedPointerString unsignedIntegerValue]: unrecognized selector sent to instance 0x964eda74bb606deb 2023-06-12 13:52:36.815 xcodebuild[22356:3140982] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString unsignedIntegerValue]: unrecognized selector sent to instance 0x964eda74bb606deb' *** First throw call stack: ( 0 CoreFoundation 0x000000019e2f7154 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000019de164d4 objc_exception_throw + 60 2 CoreFoundation 0x000000019e39e110 -[NSObject(NSObject) __retain_OA] + 0 3 CoreFoundation 0x000000019e25f0a0 ___forwarding___ + 1600 4 CoreFoundation 0x000000019e25e9a0 _CF_forwarding_prep_0 + 96 5 Localization 0x0000000108eb6cbc -[LOCStringsdataFile initWithPropertyListRepresentation:error:] + 140 6 Localization 0x0000000108eb6984 -[LOCStringsdataFile initWithJSONData:error:] + 124 7 Localization 0x0000000108eb6564 -[LOCStringsdataFile initWithContentsOfURL:error:] + 124 8 Localization 0x0000000108f2fc50 -[LOCRequest _preprocessStringsdata:error:] + 376 9 Localization 0x0000000108f2f490 __19-[LOCRequest start]_block_invoke_3 + 112 10 Foundation 0x000000019f1d9254 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24 11 Foundation 0x000000019f1d9114 -[NSBlockOperation main] + 104 12 Foundation 0x000000019f1d90a4 __NSOPERATION_IS_INVOKING_MAIN__ + 16 13 Foundation 0x000000019f1d84bc -[NSOperation start] + 708 14 Foundation 0x000000019f1d81f0 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 16 15 Foundation 0x000000019f1d80e0 __NSOQSchedule_f + 172 16 libdispatch.dylib 0x000000019dfff518 _dispatch_block_async_invoke2 + 148 17 libdispatch.dylib 0x000000019dff0400 _dispatch_client_callout + 20 18 libdispatch.dylib 0x000000019dff3884 _dispatch_continuation_pop + 504 19 libdispatch.dylib 0x000000019dff2eec _dispatch_async_redirect_invoke + 584 20 libdispatch.dylib 0x000000019e001e98 _dispatch_root_queue_drain + 396 21 libdispatch.dylib 0x000000019e0026c0 _dispatch_worker_thread2 + 164 22 libsystem_pthread.dylib 0x000000019e19c038 _pthread_wqthread + 228 23 libsystem_pthread.dylib 0x000000019e19ad94 start_wqthread + 8 ) ** INTERNAL ERROR: Uncaught exception ** Uncaught Exception: -[NSTaggedPointerString unsignedIntegerValue]: unrecognized selector sent to instance 0x964eda74bb606deb Stack: 0 __exceptionPreprocess (in CoreFoundation) 1 objc_exception_throw (in libobjc.A.dylib) 2 -[NSObject(NSObject) __retain_OA] (in CoreFoundation) 3 ___forwarding___ (in CoreFoundation) 4 _CF_forwarding_prep_0 (in CoreFoundation) 5 -[LOCStringsdataFile initWithPropertyListRepresentation:error:] (in Localization) 6 -[LOCStringsdataFile initWithJSONData:error:] (in Localization) 7 -[LOCStringsdataFile initWithContentsOfURL:error:] (in Localization) 8 -[LOCRequest _preprocessStringsdata:error:] (in Localization) 9 __19-[LOCRequest start]_block_invoke_3 (in Localization) 10 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ (in Foundation) 11 -[NSBlockOperation main] (in Foundation) 12 __NSOPERATION_IS_INVOKING_MAIN__ (in Foundation) 13 -[NSOperation start] (in Foundation) 14 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ (in Foundation) 15 __NSOQSchedule_f (in Foundation) 16 _dispatch_block_async_invoke2 (in libdispatch.dylib) 17 _dispatch_client_callout (in libdispatch.dylib) 18 _dispatch_continuation_pop (in libdispatch.dylib) 19 _dispatch_async_redirect_invoke (in libdispatch.dylib) 20 _dispatch_root_queue_drain (in libdispatch.dylib) 21 _dispatch_worker_thread2 (in libdispatch.dylib) 22 _pthread_wqthread (in libsystem_pthread.dylib) 23 start_wqthread (in libsystem_pthread.dylib) [1] 22356 abort xcodebuild -exportLocalizations -project ./MyProject.xcodeproj da
Posted
by
Post marked as solved
3 Replies
1.6k Views
Our app is not localized but we want to begin the localization process starting with push notifications we are going to integrate. The documentation notes: you can store your message strings in the Localizable.strings file of your app bundle and use the title-loc-key, subtitle-loc-key, and loc-key payload keys to specify which strings you want to display String Catalogs in Xcode 15 supersedes Localizable.strings. How do you support this when using String Catalogs? Do you just manually add a Localizable.xcstrings file to your project then manually add a new entry for your loc-key, and the system will find this string without issue? Or will we need to have a Localizable.strings file too?
Posted
by
Post marked as solved
6 Replies
2.8k Views
Hello, do the String Catalogs (new in Xcode 15) support Swift Packages? I've tried adding a new Localizable.xcstrings (string catalog) file to my package's resources folder. Great! I then see this screen: All good so far. I then try to go and build my Swift Package... and nothing changes. The string catalog is never populated and I'm left with the same screen as above. So, do string catalogs not support packages at this time or am I doing something wrong? I was really hoping String Catalogs would work and save the day since Export Localizations also does not work for Swift packages that don't support macOS. 😔
Posted
by
Post not yet marked as solved
2 Replies
845 Views
When I set my iOS app’s language to Spanish for example, then when I reboot my phone, my home and Lock Screen widgets revert back to the phone’s language, which I have set to English. If I open the app it’s still set to Spanish so it’s correct within the app; only the home and Lock Screen widgets revert back to English. The only way to get it back to Spanish is by going to my app’s setting, and setting the preferred language to English then back to Spanish again.
Posted
by
Post marked as solved
1 Replies
1.2k Views
Hey, I'm trying the new strings catalog, and I have a script that I would like to run on the xcstrings json. My question is there some documentation on the json format (what keys can it have, and values)? Also, I didn't try it yet, but what if I set for example 50 languages and 1000 localization keys, is that json really scalable? It could grow quite large, would xcode still keep it as one big file, or it would somehow split it into chunks? Would be happy for any info from the dev teams, thanks!
Posted
by
Post not yet marked as solved
2 Replies
1k Views
I'm trying to localize an iOS App Intent, but my strings are in a different table/file ("AppIntents.strings"). For this reason I'd like to create a wrapper that automatically sets this table. However, this only seems to work when I directly set the LocalizedStringResource. If I create a method that returns it, it does not work. Using a static property also does not seem to work. In these two cases, it seems to fall back to the class name of my intent ("ExampleIntent"). Below is an example of what I've tried. Is there a way to make this work? @available(iOS 16, *) extension LocalizedStringResource { static func demo(_ key: String.LocalizationValue) -> LocalizedStringResource { LocalizedStringResource(key, table: "AppIntents") } static var demo2: LocalizedStringResource { LocalizedStringResource("localization.key", table: "AppIntents") } } @available(iOS 16, *) struct ExampleIntent: AppIntent { // This works static var title: LocalizedStringResource = LocalizedStringResource("localization.key", table: "AppIntents") // This does not work // static var title: LocalizedStringResource = .demo("localization.key") // This does not work either // static var title: LocalizedStringResource = .demo2 func perform() async throws -> some IntentResult { return .result() } }
Posted
by
Post not yet marked as solved
2 Replies
818 Views
I have some .strings file for translation in my app and it turns out one of them is pretty bad. I have a new translator and I'm looking to make the process as easy for him as possible. Ideally, he would have just one file with my original english translation on the right, and the corresponding chinese translation on the right, making him easily be able to edit if necessary. The issue I see here is that is to create that file and then rebuild the .strings file. Is it possible? How would you do it? Best
Posted
by
Post not yet marked as solved
0 Replies
619 Views
Seems like a bug on the Xcode 15.0 beta. Steps to reproduce: Create a new empty Static Library project in Xcode (objective-C) Add a String Catalog file Add a dummy function which includes NSString *str = NSLocalizeString(@"test string", @"comment"); Build the project. Result: String Catalog is empty while it should be updated with "test string". I submitted FB12408229 Anyone encountered this? Anyone from Apple can kindly confirm?
Posted
by
Post not yet marked as solved
1 Replies
1.4k Views
In my project I have 3 targets. A macOS target, a target for iPhone and a target for iPad. The macOS App has an own Localizable file and I have been able to convert this to string catalog without any issues. I like this catalog! But when I try to convert the Localizable file that is shared between 2 targets, then targets fail to compile afterwards with the following error message: ...mul.lproj/Localizable.xcstrings:1:1 Localizable.xcstrings cannot co-exist with other .strings or .stringsdict tables with the same name. Does anybody have an idea how I can resolve this? Do I need to keep individual copies of the Localizable file for these 2 targets?
Posted
by
Post not yet marked as solved
0 Replies
631 Views
We use a localization service that allows us to export our translated strings in .xliff format. When I import the spanish (es.xliff) file into the string catalogs it imports the english keys and leaves the spanish translation column empty, which causes it to default to English. I created feedback 12429535 and 12429469 because it seems the feedback site is broken and shows it cannot find the feedback I just submitted.
Posted
by
Post not yet marked as solved
2 Replies
913 Views
Hi, I've been using string files to localize incoming remote notifications like this: "training_new_title" = "New training added"; "training_new_body" = "A new training on %@ has been added"; Following the migration to the new string dicts it looks like this: "training_new_body" : { "extractionState" : "manual", "localizations" : { "en" : { "stringUnit" : { "state" : "translated", "value" : "A new training on %@ has been added" } }, "nl" : { "stringUnit" : { "state" : "translated", "value" : "Een nieuwe training op %@ is toegevoegd" } } } }, "training_new_title" : { "extractionState" : "manual", "localizations" : { "en" : { "stringUnit" : { "state" : "translated", "value" : "New training added" } }, "nl" : { "stringUnit" : { "state" : "translated", "value" : "Nieuwe training toegevoegd" } } } }, Unfortunately as said before notifications are no longer localized and come in as their normal state: "training_new_title" & "training_new_body" . I am using Firebase messaging service, they send a APNS, that looks like this: notification: { titleLocKey: "training_new_title", bodyLocKey: "training_new_body", bodyLocArgs: bodyPayload, } Do string dicts require any extra steps apart from the standard that I have implemented? func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { completionHandler(.newData) } Thanks in advance for any insights
Posted
by
Post not yet marked as solved
1 Replies
877 Views
I migrated to String Catalog in my app. That worked fine, and everything is OK in the Simulator and even on a real device. However, After I deployed the App and it became available in the AppStore, I started receiving Feedback from some users. Seems my app is no longer doing localization. It always presents itself in its development language. Has anyone else experienced this?
Posted
by