English 中文(简体)
能否将参数输入翻译档案中的翻译句子?
原标题:Is it possible to pass parameters into a translated sentence in a .po translation file?
  • 时间:2009-09-18 11:22:12
  •  标签:

I am using .po and .mo files for translating my website. My question is, is it possible to pass parameters into a translated sentence in a .po translation file?

For example: en -> Hi, my name is Sarah, and I am an alcoholic I want to translate that sentence using two params, name (Sarah) and profession (an alcoholic).

事先感谢你。

问题回答

这取决于语言,但基本上是,你总是能够做到。

printf(_("Hi, my name is %s and I am %s"), name, prof);

页: 1

echo sprintf(_("Hi, my name is %s and I am %s"), $name, $prof);

载于 php。

alert( _( Hi, my name is %s and I am %s )
    .replace( %s ,name).replace( %s ,prof) );

a) 包括:

alert( _( Hi, my name is %1 and I am %2 )
    .replace( %1 ,name).replace( %2 ,prof) );

或者说,你可以向股东提出什么。 course 课程的实施取决于是否在预处理时间或作为操作时间强调功能提供翻译机制。

等等。

这是一个老话题,但仅提及......

在许多语言中,你还可以指出什么理由想要使用(在PHP):

$name =  Agustinus ;
printf(_("Hi %1$s.
 The owner of this page is: %1$s. Today is %s.", 
   $name, date( d-m-Y ));




相关问题
热门标签