1

I'm trying to localize an array for different languages.

The array that I want localize looks like:

var watch = ["This watch is blue", "this watch is red", "this watch is white "]

I have already the string localizable and I'm using the method NSLocalizedString but I don't know how I can localize the array with all different description.

Thank you for the help

1
  • 1
    You could use NSLocalizedString for your array instead of an array of vanilla strings. Commented Dec 17, 2018 at 19:44

1 Answer 1

7

If you are already setup the localization in your app, you could still use the NSLocalizedString in for the array elements instead of direct strings.

Assuming that you have a Localizable.strings as:

"BlueMessage" = "This watch is blue";
"RedMessage" = "this watch is red";
"WhiteMessage" = "This watch is white ";

then you could declare watch array as:

var watch = [NSLocalizedString("BlueMessage", comment: ""),
             NSLocalizedString("RedMessage", comment: ""),
             NSLocalizedString("WhiteMessage", comment: "")]

It would be also an array of strings ([String]), containing the localized versions of the strings.

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

Comments

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.