This is a function defined in the Foundation Framework. It returns a localized version of a string.
Questions tagged [nslocalizedstring]
410 questions
311
votes
7 answers
How to provide a localized description with an Error type in Swift?
I am defining a custom error type with Swift 3 syntax and I want to provide a user-friendly description of the error which is returned by the localizedDescription property of the Error object. How can I do it?
public enum MyError: Error {
case…

Evgenii
- 36,389
- 27
- 134
- 170
272
votes
28 answers
How to force NSLocalizedString to use a specific language
On iPhone NSLocalizedString returns the string in the language of the iPhone.
Is it possible to force NSLocalizedString to use a specific language to have the app
in a different language than the device ?

CodeFlakes
- 3,671
- 3
- 25
- 28
247
votes
18 answers
What's NSLocalizedString equivalent in Swift?
Is there an Swift equivalent of NSLocalizedString(...)?
In Objective-C, we usually use:
NSString *string = NSLocalizedString(@"key", @"comment");
How can I achieve the same in Swift? I found a function:
func NSLocalizedString(
key: String,
…

Rafał Sroka
- 39,540
- 23
- 113
- 143
146
votes
9 answers
Best practice using NSLocalizedString
I'm (like all others) using NSLocalizedStringto localize my app.
Unfortunately, there are several "drawbacks" (not necessarily the fault of NSLocalizedString itself), including
No autocompletition for strings in Xcode. This makes working not only…

JiaYow
- 5,207
- 3
- 32
- 36
104
votes
1 answer
iOS 8.1 Simulator Localization broken (NSLocalizedString)
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…

natanavra
- 2,100
- 3
- 18
- 24
104
votes
8 answers
How to use NSLocalizedString function with variables in Swift?
I'm trying to localize my app using NSLocalizedString. When I import the XLIFF file, most works like a charm but something do not and some string is not localized. I have noticed that the problem is from NSLocalizedString containing something…

msalafia
- 2,703
- 5
- 23
- 34
61
votes
8 answers
Possible to use variables and/or parameters with NSLocalizedString?
I have tried using a variable as an input parameter to NSLocalizedString, but all I am getting back is the input parameter. What am I doing wrong? Is it possible to use a variable string value as an index for NSLocalized string?
For example, I have…

futureelite7
- 11,462
- 10
- 53
- 87
58
votes
7 answers
How to localize an iOS storyboard
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…

dhrm
- 14,335
- 34
- 117
- 183
48
votes
30 answers
NSLocalizedString only retrieves the key, not the value in Localizable.strings (IOS)
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…

Smiden
- 645
- 1
- 6
- 11
42
votes
4 answers
NSLocalizedString with format
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…

Peter Warbo
- 11,136
- 14
- 98
- 193
40
votes
3 answers
Do I need English beside Base localization which would contain the exact same 'translation'?
I'd expect the base file to contain my English words since my project has "Localization native development region" set to English.
Update - to clarify my question:

Pieter
- 1,751
- 3
- 30
- 65
39
votes
1 answer
How to make iOS app name localizable?
I'm trying to find the easiest way to localize my app. I'm using sqlite, so I need basically only to switch my database name. Problem is the app name - can it be localized from code or I have to make x apps for x languages, so anyone will have app…

raistlin
- 4,298
- 5
- 32
- 46
34
votes
1 answer
Multi-line strings in objective-c localized strings file
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…

Christopher Pickslay
- 17,523
- 6
- 79
- 92
20
votes
4 answers
Fallback language iOS (with incomplete Localizable.strings file)
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…

Georg
- 3,664
- 3
- 34
- 75
19
votes
4 answers
How to use Localizable.strings stored in a CocoaTouch Framework?
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…

Bernd
- 11,133
- 11
- 65
- 98