在Zend Framework中创建静态多语言网站的最佳方法/工具是什么?

时间:2011-08-10 09:09:50

标签: zend-framework

目标是创建一个大约50页的网站。内容将是静态的(无编辑,无更改)将有图片,文本段落,无序列表。并且......三种语言(未来可能更多)。我想要翻译网址。必须使用Zend Framework。没有数据库可以使用。

如何在这种情况下处理内容?将它存储为变量,并使用$ this-> translate(),或以某种方式标记它,并在模板中使用标签?

1 个答案:

答案 0 :(得分:0)

我会说除了网站的“默认”语言之外,还要为每种语言使用翻译数组。如果可以(没有测试,但我发现它可能),您可以使用“默认”语言文本作为这些数组的键。这样,当您将翻译文件发送给必须进行实际翻译的人时,他们会将某些引用作为他们正在翻译的文本的上下文。

不要害怕在翻译文件中使用过多的评论,这样可以让那些必须翻译文本的人更轻松。

即:

// This section of text is used to diplays the time since the last status update
/*
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc odio nisi, varius eget
vulputate ut, cursus sit amet ligula. Maecenas dui leo, placerat et ultricies ac, 
pulvinar sit amet metus. Mauris leo erat, vehicula sed interdum sed, condimentum ac 
leo. Ut congue arcu ac arcu interdum egestas.

Last update - 4 hours ago
*/
array(
    'Last update' => 'Dernière mise à jour',
    '%hours% hours ago' => 'il y a %hours% heures',
    'One hour ago' => 'il y a une heure'
)

// %hours% is a variable place holder to be replaced by you programatically

通过这种方式,进行翻译的人甚至不需要访问实际的网站(以后可以智能地访问以进行修改和更正)。