nslocalizedstring

iPhone app using different language than the one set in OS / device?

空扰寡人 提交于 2019-12-05 02:27:51
问题 Is it possible to have my app running in a different language than the one that is set in the OS? I want to have a language switch in my app’s setting menu, where the user can e.g. select german for the app, while his system is running in english. From what I’ve already read, it seems it’s not possible without having my own localization mechanism… What do you think? Cheerz, pawi 回答1: You need to implement your custom resource loading mechanism to achieve that. For example you will no longer

iOS Get localized version of a string for a specific language

冷暖自知 提交于 2019-12-04 18:10:44
问题 I'm building an application for iOS that will be available in both English and French languages. I've read some tutorials around internationalization and I have an understanding of how it works and what I need to do. The problem I'm having is there is a specific case where I want to load French strings for an English user. I understand it's possible to set the language for the entire application, but that it requires the application to be restarted before it will take affect. I'd like to

How does localizedStringWithFormat work?

◇◆丶佛笑我妖孽 提交于 2019-12-04 17:12:11
问题 Please note I am not asking about NSLocalizedString() the macro. I am asking about the NSString class function + (instancetype)localizedStringWithFormat:(NSString *)format, ... . These are two separate things. Question I'm trying to use the NSString class method localizedStringWithFormat but I just can't work out how I'm supposed to use it. Whatever I try I don't seem to get the words to appear in the translation file using Xcode 6 export for localization . I've tried the top two variations

localize existing iOS app

℡╲_俬逩灬. 提交于 2019-12-04 16:28:31
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) . Sure I could do this manually with search and replace, but I can't believe there's no tool for this. I

Change iphone app language with buttons and without restart of the app

ぐ巨炮叔叔 提交于 2019-12-04 03:47:57
问题 I want to change the language of my app. At the moment I am doing it at the following way. I have two buttons which are change the languages in NSUserDefaults. But before this affects my app I need to restart it. Here is my code. - (IBAction)changeDutch:(id)sender { [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"nl", @"en", nil] forKey:@"AppleLanguages"]; } - (IBAction)changeEnglish:(id)sender { [[NSUserDefaults standardUserDefaults] setObject:[NSArray

Unicode not converted when displayed

半世苍凉 提交于 2019-12-04 03:15:30
问题 I'm localizing an app to spanish, and characters are encoded in the Localizable.strings file for that language using Unicode. For example, I have the entry: "login.saveSettings"="Guardar configuraci\\u00F3n:"; which is displayed in a UILabel exactly like that ("Guardar configuraci\\u00F3n:"), instead of "Guardar configuración:". I tried different variations, such as "\u00F3", or "\\U00F3", but without any success. I use NSLocalizedString this way: self.saveSettingsLabel.text =

How to use Localizable.strings stored in a CocoaTouch Framework?

这一生的挚爱 提交于 2019-12-04 01:23:44
I'd like to add multi-language support to a CocoaTouch Framework. The problem: The Localizable.strings file I created only gets used by NSLocalizedString when it's part of the main app and its target. I'd like to store it inside the Framework to keep things separate. How can I use the Localizable.strings when placed inside a CocoaTouch Framework? Use: NSLocalizedString("Good", tableName: nil, bundle: NSBundle(forClass: self), value: "", comment: "") or you can create public func like this: class func POLocalized(key: String) -> String{ let s = NSLocalizedString(key, tableName: nil, bundle:

Multi-line strings in objective-c localized strings file

爷,独闯天下 提交于 2019-12-03 22:07:49
I have a template for an email that I've put in a localized strings file, and I'm loading the string with the NSLocalizedString macro. I'd rather not make each line its own string with a unique key. In Objective-C, I can create a human-readable multiline string like so: NSString *email = @"Hello %@,\n" "\n" "Check out %@.\n" "\n" "Sincerely,\n" "\n" "%@"; I tried to put that in a .strings file with: "email" = "Hello %@,\n" "\n" "Check out %@.\n" "\n" "Sincerely,\n" "\n" "%@"; But I get the following error at build time: CFPropertyListCreateFromXMLData(): Old-style plist parser: missing

iPhone app using different language than the one set in OS / device?

不羁的心 提交于 2019-12-03 20:20:57
Is it possible to have my app running in a different language than the one that is set in the OS? I want to have a language switch in my app’s setting menu, where the user can e.g. select german for the app, while his system is running in english. From what I’ve already read, it seems it’s not possible without having my own localization mechanism… What do you think? Cheerz, pawi You need to implement your custom resource loading mechanism to achieve that. For example you will no longer be able to use NSLocalizedString macro or [NSBundle pathForResource:]. You will always have to specify paths

Overriding preferred strings localization on the fly for testing

拟墨画扇 提交于 2019-12-03 13:56:30
问题 Using the Settings app in the iPhone simulator to switch languages is a PITA way of testing localization tweaks. I'm trying to figure out a way to switch localizations (en/fr/es/etc) on the fly in my app with a debug setting without restarting the app. NSBundle provides ways of requesting localized resources from an arbitrary localization, e.g. - (NSString *)pathForResource:(NSString *)name ofType:(NSString *)extension inDirectory:(NSString *)subpath forLocalization:(NSString *