nslocalizedstring

Localize a float and specify number of decimal places in iOS

时间秒杀一切 提交于 2019-12-01 03:34:34
问题 I have a float that I'd like to display to one decimal place. E.g. 104.8135674... to be displayed as 104.8 in English. Usually I'd use: myString = [NSString stringWithFormat:@"%.1f",myFloat]; However, I'd like to localize the number, so I tried: myString = [NSString localizedStringWithFormat:@"%.1f",myFloat]; This works to assign the correct decimal symbol (e.g. English: 104.8 German: 104,8 However, for languages that use don't use arabic numerals (0123456789), the correct decimal symbol is

Fallback language iOS (with incomplete Localizable.strings file)

折月煮酒 提交于 2019-11-30 17:20:11
I have an iOS project that is localized into 16 languages. Only some words are not localized (Mainly those that go into an update and the localization office did not deliver in time). For my keys I do not use the english wording, as this can also change if a translator wishes. So now if I just don't have a translation for a language, if falls back to the key that I used. But as this key is not 'human readable' or at least not 'human enjoyable to read' this is a problem. I did some research but couldn't find a solution to my exact problem. I have fe.: Localizable.strings in en.lproj @"Key1" = @

Fallback language iOS (with incomplete Localizable.strings file)

我们两清 提交于 2019-11-30 00:47:13
问题 I have an iOS project that is localized into 16 languages. Only some words are not localized (Mainly those that go into an update and the localization office did not deliver in time). For my keys I do not use the english wording, as this can also change if a translator wishes. So now if I just don't have a translation for a language, if falls back to the key that I used. But as this key is not 'human readable' or at least not 'human enjoyable to read' this is a problem. I did some research

AppleLanguages value overrides the value of language set in IOS settings preferred language

北战南征 提交于 2019-11-29 13:02:59
I am working on Localization of my app that supports both spanish and English languages.These options are listed in a tableview.On clicking English i am setting the value "en" for the key "AppleLanguages" in NSUserDefaults.So that it can show the content in English. NSUserDefaults *nsdefault=[NSUserDefaults standardUserDefaults]; [nsdefault setObject:[NSArray arrayWithObject:@"en"] forKey:@"AppleLanguages"]; [nsdefault synchronize]; Also at the same time i am trying to fetch the Language programmatically from IOS device which was set at General>>International>>Language manually using code.

How to set font family to Navigation Controller Title in swift?

无人久伴 提交于 2019-11-28 14:38:50
I have one View Controller named "Home". I embed it in Navigation Controller. self.navBar.topItem?.title = "Home" I would like to change "Tharlon" font to my UIViewController title bar. self.navBar.topItem?.title = NSLocalizedString("Home", comment: "") self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "Tharlon", size: 17)!] Both these codes are in ViewDidLoad() function. When I run the app, Translated text shows well at the first time. Then, I open other menus and goes back to Home. At that second time, translated text does not show well and it

Custom NSLocalizedString?

天大地大妈咪最大 提交于 2019-11-28 12:43:18
Is it possible to use the NSLocalizedString infrastructure (based on localizable.strings) with a custom-defined "localization"? The thing is, there are some languages that have different wordings for males and females. I want to ask the user's gender on first launch and then use the appropriate phrases. Of course, both are based on the same language. I can do it with my own code but I'd rather do it the easy way if possible. NSLocalizedString is just a macro defined in NSBundle.h Redefine it or create a new one, for example NSGenderAwareLocalizedString to fit your needs. With the new macro,

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

做~自己de王妃 提交于 2019-11-28 12:33:49
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.description) printIt(odd) I see what I expect to see: No way, José No way, José However, when I write (

Advanced Localization with Omission of Arguments in Xcode

爱⌒轻易说出口 提交于 2019-11-28 12:22:22
I have this formatted string that I am having a translator work on. ENGLISH "Check out the %1$@ %2$@ in %3$@: %4$@" = "Check out the %1$@ %2$@ in %3$@: %4$@" GERMAN TRANSLATION "Check out the %1$@ %2$@ in %3$@: %4$@" = "Hör Dir mal %2$@ in %3$@ an: %4$@"; These are passed to a [NSString stringWithFormat:] call: ////////////////////////////////////// // Share Over Twitter NSString *frmt = NSLocalizedString(@"Check out the %1$@ %2$@ in %3$@: %4$@", @"The default tweet for sharing sounds. Use %1$@ for where the sound type (Sound, mix, playlist) will be, %2$@ for where the audio name will be, %3$@

NSLocalizedString with format

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 08:53:56
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)]; [NSString stringWithFormat:NSLocalizedString(@"Is “%@“ still correct for “%@“ tap “OK“ otherwise tap “Change“ to choose new contact details", @"Query if parm 1 is still correct for parm 2"), individual.contactInfo,

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

☆樱花仙子☆ 提交于 2019-11-28 08:23:27
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)? You can retrieve all of the string keys by reading in English.lproj/Localizable.strings as a dictionary and fetching its keys: NSString