nslocalizedstring

Ios Localization not working

不问归期 提交于 2019-12-23 18:39:29
问题 I have XCode Version 4.3.3 running and iOS 5.1. i can do what i want. i can't get localization running. i added different languages through project files. I adjusted the InfoPlist.strings in every Language like this: "key" = "value"; I have everywhere: NSLocalizedString(@"key", nil); No key is the same like its value. I have checked the which language is chosen: NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0]; But the app constantly just shows the keys and no value when

localize existing iOS app

大兔子大兔子 提交于 2019-12-21 23:02:49
问题 I can't believe this hasn't been asked before (either I'm too unorganized in my coding practices or I didn't use the right keywords): How can I localize an existing iOS app that doesn't use NSLocalizedString (specifically just the first step, converting all strings literals to NSLocalizedString)? I understand how the localization process works, but I don't want to change all texts myself. Surely there must be a tool that can convert @"Hello World" to NSLocalizedString(@"Hello World", nil) .

iOS: How to localize strings with multiple interpolated parameters?

爷,独闯天下 提交于 2019-12-19 19:50:23
问题 How do I use NSLocalizedString to build a string with multiple parameters while giving the translator control to change the order if they wish? An example in my Localizable.string is: "score_out_of"="Your score is %i out of %i"; And would be invoked like [NSString stringWithFormat:NSLocalizedString(@"score_out_of", nil), correct, total]; But on some locales the grammar rules might dictate that total goes before correct. In Objective C it seems the interpolation order is hard coded. In other

Dynamic/runtime dispatch in Swift, or “the strange way structs behave in one man's opinion”

元气小坏坏 提交于 2019-12-17 20:38:03
问题 I'm not horribly new to Swift, nor to Objective-C, but I saw some odd behavior when working with an Error subtype today that led me to dig a little deeper. When working with an NSString subclass (yes, the below example functions similarly for classes not based on NSObject ): import Foundation // Class version class OddString : NSString { override var description: String { return "No way, José" } } let odd = OddString() func printIt(_ string: NSString) { print(string.description) } print(odd

NSLocalizedString with format

一世执手 提交于 2019-12-17 18:45:58
问题 How would I use NSLocalizedString for this string: [NSString stringWithFormat:@"Is “%@“ still correct for “%@“ tap “OK“ otherwise tap “Change“ to choose new contact details", individual.contactInfo, individual.name]; When using stringWithFormat before I've used it in the following manner: [NSString stringWithFormat:@"%d %@", itemCount, NSLocalizedString(@"number of items", nil)]; 回答1: [NSString stringWithFormat:NSLocalizedString(@"Is “%@“ still correct for “%@“ tap “OK“ otherwise tap “Change“

Multiple Localized .strings Files in iOS App Bundle

放肆的年华 提交于 2019-12-17 18:42:13
问题 I have a fairly complicated project, consisting of several large localized sub-projects. Most of my sub-projects are localized through a single Localizable.strings file. This file is copied into a SubProjectName.bundle target, which is used in conjunction with a SubProjectName.a static library in the main project. This works fine. However, one of my sub-projects contains many localized .strings files. This project fails to read strings in any language other than English , regardless of how

iPhone/iOS: How can I get a list of localized strings in all the languages my app is localized in?

こ雲淡風輕ζ 提交于 2019-12-17 18:37:57
问题 I need to send my server a list of localizations for a particular string. Meaning, if my app has a string Foo which is localized as @"Foo" in English and @"Фу" in Russian, I'd like to send the server a list such as this: String Foo: English: "Foo" Russian: "Фу" What I think I need to be able to do is: Enumerate localized strings for each language my app is localized for Get the localized version of Foo for each language How do I do (1) and how do I do (2)? 回答1: You can retrieve all of the

iOS 8.1 Simulator Localization broken (NSLocalizedString)

回眸只為那壹抹淺笑 提交于 2019-12-17 17:27:23
问题 TL;DR: It seems localization does not work with xCode 6.1 and 8.1 simulator. Workaround: Go to "edit schemes" >> "Run" (side bar) >> "Options" tab >> "Application Language" Select the language you wish to run the app on the simulator. Long Story: I've updated xCode to 6.1. The update deleted the iOS 7.x simulators and left me only with 8.x simulator. I've done the following steps: I've installed the 7.x simulator Cleaned the project Deleted the app from the simulators Deleted the derived

NSLocalizedString only retrieves the key, not the value in Localizable.strings (IOS)

孤街浪徒 提交于 2019-12-17 15:53:24
问题 I've made a strings file named "Localizable.strings" and added two languages to it, like so: "CONNECTIONERROR" = "Check that you have a working internet connection."; "CONNECTIONERRORTITLE" = "Network error"; I have also converted the files to Unicode UTF-8 However, when I create a UIAlertView like this: UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"CONNECTIONERRORITLE",nil) message:NSLocalizedString(@"CONNECTIONERROR",nil) delegate:self cancelButtonTitle:@"Ok"

How to localize an iOS storyboard

泪湿孤枕 提交于 2019-12-17 10:12:03
问题 I've an iPhone storyboard with some views. For instance, a navigation item title is named News , which should be translated for other languages. When I add a new localization to my storyboard, it created a duplicate of my current storyboard for the new language. Here I can change the title for the navigation item, but for me it does not seem very useful. What if my storyboard contains 100 views and I need to support 10 languages? If I need to change something in my original storyboard, I have