gpt4 book ai didi

iOS 游戏本地化与字符串格式

转载 作者:行者123 更新时间:2023-11-29 13:15:40 25 4
gpt4 key购买 nike

<分区>

我想在句子中本地化带有数字的字符串。我不使用 iOS 的 Localizable.strings 文件,因为它既乏味又容易出错,我可能会决定稍后重新措辞。

这是我做的:

#define sf_buy_bombs @"Are you sure you want to buy %i bombs for $%i? "

其中'sf'后缀表示'字符串格式'

这是我需要使用它的时候:

[NSString stringWithFormat: [Helper getLocalizedStringWithString:sf_buy_bombs], num_shop_items_bundle, price_bombs]

和一个处理翻译的辅助方法

+(NSString*) getLocalizedStringWithString: (NSString*) str {
if ([Helper isSimplifiedChinese]) {
if ([str isEqualToString:sf_buy_bombs]) {
return @"确定要购买%i个炸弹道具吗? ($ %i)";
}
}
return str;
}

最终显示的标签是“确定要购买%i个炸弹道工具吗?($%i)”,数字没有代入。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com