Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The right way to localize in my application

I've read few tutorials, but each one says something different and I've got really confused. What is the propiret way to localize my application?

some says like this:

NSLocalizedString(@"Welcome to app", @"Welcome title label");

and other says:

NSLocalizedString(@"AppWelcomeMessage", nil);

And in the Localizable.strings, I need to set like this:

"AppWelcomeMessage" = "Welcome to my application!";

Is the comment in NSLocalizedString(key,comment) is just a description of the key? or it's important and have an effect on the translation itself? what is the right order?

Thanks for helping!

like image 457
ytpm Avatar asked Oct 24 '25 03:10

ytpm


2 Answers

Is the comment in NSLocalizedString(key,comment) is just a description of the key?

Yes. If you don't need it, feel free to ignore it (pass in nil).

In fact, when writing a lot of localizable strings in code, it starts being annoying to spell out NSLocalizedString(@"Some Key", @"Some Comment") every single time. What I generally do is

#define L(k) NSLocalizedString(k, nil)

and it's suddenly a joy to localize my application.

The comment in NSLocalizedString is for the use of genstrings. You can leave it nil if you do all your localizations yourself. Otherwise, you should make an effort to add a meaningful piece of information to help the people who do localizations for you. Improving their understanding of the context in which the translation is to be made has direct impact on the quality of the translations that you are going to get.

like image 35
Sergey Kalinichenko Avatar answered Oct 25 '25 21:10

Sergey Kalinichenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!