我有这种格式化的字符串,我有一个翻译工作。在Xcode中省略参数的高级本地化
ENGLISH
"Check out the %[email protected] %[email protected] in %[email protected]: %[email protected]" = "Check out the %[email protected] %[email protected] in %[email protected]: %[email protected]"
德文译本
"Check out the %[email protected] %[email protected] in %[email protected]: %[email protected]" = "Hör Dir mal %[email protected] in %[email protected] an: %[email protected]";
这些传递给[NSString stringWithFormat:]
电话:
//////////////////////////////////////
// Share Over Twitter
NSString *frmt = NSLocalizedString(@"Check out the %[email protected] %[email protected] in %[email protected]: %[email protected]", @"The default tweet for sharing sounds. Use %[email protected] for where the sound type (Sound, mix, playlist) will be, %[email protected] for where the audio name will be, %[email protected] for the app name, and %[email protected] for where the sound link will be.");
NSString *urlString = [NSString stringWithFormat:@"sounds/%@", SoundSoundID(audio)];
NSString *url = ([audio audioType] == UAAudioTypeSound ? UrlFor(urlString) : APP_SHORTLINK);
NSString *msg = [NSString stringWithFormat:
frmt,
[[Audio titleForAudioType:[audio audioType]] lowercaseString],
[NSString stringWithFormat:@"\"%@\"", AudioName(audio)],
APP_NAME,
url];
returnString = msg;
随着期望的和实际的结果:
ENGLISH
desired: "Check out the sound "This Sound Name" in My App Name: link_to_sound" actual: "Check out the sound "This Sound Name" in My App Name: link_to_sound"
GERMAN
desired: "Hör Dir mal "This Sound Name" in My App Name an: link_to_sound" actual: "Hör Dir mal sound in "This Sound Name" an: My App Name"
,通过在-[NSString stringWithFormat:]
使用编号变量技术问题 的问题是,我的假设下,我可以做像这样的ngs,其中%[email protected]
变量被完全省略。如果您注意到,格式字符串的德语翻译根本不使用第一个参数(%[email protected]
),但它仍然出现在输出字符串中(“声音”)。
我在做什么错?
看来我所做的错在于对编号变量的省略进行假设。 – coneybeare 2010-06-01 15:08:28
有趣的是,这在Android/Java中可以正常工作;必须是他们的(无效的)实现 – Opus1217 2016-01-01 18:50:01