I'm trying to translate my application and I find it difficult to translate when there are half a placeholder. I need to locate the following code:
[textView1 insertText:[NSString stringWithFormat:@"%@ è il %i/%i/%i. Il giorno delle settimana è %@. La Festa è compresa nel calcolo. \n", nomeFesta, giornoFesta, meseFesta, annoFestaModificato, ggSett]];
I put in the file localizable.string (English):
"festaCompresa" = @"%@ is the %i/%i/%i. the day of the week is %@. The holidays is included in the calculation. \n";
Then I edited the piece of code:
[textView1 insertText:[NSString stringWithFormat:NSLocalizedString(@"festaCompresaW, @""), nomeFesta, giornoFesta, meseFesta, annoFestaModificato, ggSett]];
It does not work.
Your strings file has a minor error, you've included an @
as though the string as an NSString
constant - the file format uses strings in quotes:
"festaCompresa" = "%@ is the %i/%i/%i. the day of the week is %@. The holidays is included in the calculation. \n";
BTW: when creating format strings for localization you might need to use positional formats where each format specification includes the number of the argument. For example:
"festaCompresa" = "%1$@ is the %2$i/%3$i/%4$i. the day of the week is %@. The holidays is included in the calculation. \n";
This is obviously not required in the above string as the arguments are included in the order they are provided. However in some languages they might need to be in a different order and this is how it is done.
Did you copy-paste the code? Or did you re-typed it in? Because if you copy-pasted it the problem is there:
[textView1 insertText:[NSString stringWithFormat:NSLocalizedString(@"festaCompresaW, @""), nomeFesta, giornoFesta, meseFesta, annoFestaModificato, ggSett]];
I suppose it should be
[textView1 insertText:[NSString stringWithFormat:NSLocalizedString(@"festaCompresa", @""), nomeFesta, giornoFesta, meseFesta, annoFestaModificato, ggSett]];
So basically a "
instead of W
.
Also, in Localizable.strings you don't put @
in front of the quotes, so this:
"festaCompresa" = @"%@ is the %i/%i/%i. the day of the week is %@. The holidays is included in the calculation. \n";
should be this:
"festaCompresa" = "%@ is the %i/%i/%i. the day of the week is %@. The holidays is included in the calculation. \n";
Hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With