1
我必须使用带整数值的stringWithFormat本地化detail-text-label,如下所示。如何使用%d来本地化stringWithFormat?
cell.detailTextLabel.text =
[NSString stringWithFormat:@"Remaining: %d", count];
我必须使用带整数值的stringWithFormat本地化detail-text-label,如下所示。如何使用%d来本地化stringWithFormat?
cell.detailTextLabel.text =
[NSString stringWithFormat:@"Remaining: %d", count];
例如,假设"Remaining: %d" = "Remaining: %d
是在你的英语Localizable.strings文件,"Remaining: %d" = "Restante: %d
是在西班牙的一个,下面的代码将解决您的具体问题:
cell.detailTextLabel.text =
[NSString stringWithFormat:NSLocalizedString(@"Remaining: %d", @"description for translators"), count];
如果你需要使用多个参数本地化字符串,然后上述解决方案不够灵活(在某些语言中,您可能需要更改占位符的顺序)。您可以使用positional specifiers为您的解决方案添加这种灵活性。
工作很好。感谢你的回答。 – Kalaichelvan
你能否让你更清楚你想要做什么......? –