开发者

Iphone Localizable String with another language

I'm creating an application for two languages: English and Portuguese-br

I've created a Localizable.strings for those languages.

The application works fine when the language of the device is one of above, but if the language is another, he shows only the key

Example:

Localizable.strings(English)

"participarbutton" = "join";

Localizable.strings(Portuguese-Brazil)

"participarbutton" = "participar";

On the code:

开发者_StackOverflow

[btFacaParte setTitle:NSLocalizedString(@"participarbutton", @"") forState:UIControlStateNormal]

If the language is Spanish shows the text "participarbutton"

There's a way to set a default text?


The first parameter of the NSLocalizedString function call is the default text. Unlike Keys in other programming languages, this is simply a String and the default would be the actual text in the first parameter like so if no translation string is available:

NSLocalizedString(@"This is the default text if no translation is available", @"This is some text to describe the context and information of the string to be translated");

So if you want to show the English by default, you'd do something like this in your code:

[btFacaParte setTitle:NSLocalizedString(@"Join", @"") forState:UIControlStateNormal];

Then the key would look like this in Localizable.strings (English)

"Join" = "Join";

And in Localizable.strings (Portuguese-Brazil)

"Join" = "Participar";

That way, by default it will show Join for the button if you are using any other language apart from Portuguese-Brazil

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜