Internationalization Kohana 3.x中的I18n:转换包含日期/时间等附加值的字符串

Internationalization Kohana 3.x中的I18n:转换包含日期/时间等附加值的字符串,internationalization,translation,kohana-3,Internationalization,Translation,Kohana 3,我使用的是Kohana Framework 3.x。它支持I18n,您可以通过为每种给定语言定义一个数组来本地化Web应用程序,如下所示: // application/i18n/de.php adds support for the german language like so return array ( 'language' => 'Sprache', 'house' => 'Haus' //more key-value pairs ); 在我的ph

我使用的是Kohana Framework 3.x。它支持I18n,您可以通过为每种给定语言定义一个数组来本地化Web应用程序,如下所示:

// application/i18n/de.php adds support for the german language like so
return array
(
    'language' => 'Sprache',
    'house' => 'Haus'
    //more key-value pairs
);
在我的php代码中,我可以得到如下适当的翻译:

// define current language somewhere, for example german
i18n::lang("de");

// get the translation for a given key
echo I18n::get('house'); // the key "house" obviously has to be the same for all languages
但是如果我需要翻译包含日期或时间的句子呢。例如:“2天前”需要翻译成德语中的“vor 2 Tagen”。我在运行时得到数字“2”(它可以是任何给定的数字),因此我无法在翻译数组中指定它。Kohana是否支持某种本地化,我可以在运行时添加值?

使用
SYSPATH/base.php中的
函数:

echo __('house'); // just translate 'house' 
echo __(':count days ago', array(':count' => 2)); // translate with values replacement
使用
SYSPATH/base.php
中的
\uuuu()
函数:

echo __('house'); // just translate 'house' 
echo __(':count days ago', array(':count' => 2)); // translate with values replacement