燃料观点中的i18n(国际化)

时间:2011-12-05 03:41:23

标签: php view internationalization fuelphp

在Fuel PHP的视图中处理i18n(国际化)字符串的最佳/建议方法是什么?我无法在文档中找到任何对此的引用,并且正在考虑使用gettext。有什么建议吗?

1 个答案:

答案 0 :(得分:4)

您可以使用the lang class,您可以使用它来加载您需要的语言文件。 代码示例:

<强>使用example.php

return array(
    'hello' => 'Hello :name',
    'something'=> 'something :name!',
    'test'=> array(
        'hello' => 'Hello', 
        'something' => 'Plop'
    )
);

您的文件

// Will load the file "example.php" into the "var" variable
Lang::load('example', 'var');

// Get the variable "something"
$this->output = Lang::get('var.test.something');

您可以创建不同的语言文件,例如“en,it”或更多,并根据用户的本地设置动态加载文件。