1

With localize I mean translate into different languages. I only found Instructions for localizing the storyboard but I also have strings that I set in Code. (I'm using Swift)

1

1 Answer 1

3

In short — see the NSLocalizedString function. This is also there in Swift... its declaration looks like this:

func NSLocalizedString(
    key: String,
    tableName: String? = default,
    bundle: NSBundle = default,
    value: String = default,
    #comment: String) -> String

The third through sixth arguments have default values, so you can call it like this:

NSLocalizedString("foo") // -> Maybe「フー」in your Japanese strings file?

Or like this:

NSLocalizedString("foo", comment: "metasyntactic variable")

Or with any other combination of arguments.

Check out the Internationalization and Localization Guide in Apple's documentation.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried this on my project, but I can't make NSLocalize return localized strings :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.