在属性文件中设置样式文本

时间:2015-05-28 12:43:38

标签: html css properties internationalization

我正在使用我的webapp中的属性文件来满足i18n的需求。有时,我翻译的文字需要具有独特的风格。例如:

options.reduce.co2.label = To reduce your CO2 emission, click here!

实际上应该呈现为:

To reduce your CO<span class="subscript">2</span> emission, <a href="www.blackle.com">click here</a>!

diry修复将在我的属性文件中包含此样式。但是,我真的想避免这个!

更简洁的方法是分割文本的所有部分:

options.reduce.co2.label.part1 = To reduce your CO
options.reduce.co2.label.part2 = 2
options.reduce.co2.label.part3 = emission, 
options.reduce.co2.label.part4 = click here
options.reduce.co2.label.part5 = !

然而,这使得属性文件变得很乱,而不是结构化的句子。

你如何处理这种情况?我希望为开发人员实现最大的可读性和可维护性。

1 个答案:

答案 0 :(得分:0)

我总是使用占位符来表达这种东西:

options.reduce.co2.label = To reduce your CO%s2%s emission, click %shere%s!