来源:http://trac.seagullproject.org/wiki/Modules/Cms/i18n

CMS国际化

概述

Seagull CMS模块可以根据你选择你语言生成内容以供显示。内容可以是

  • 预先定义好的文本内容
  • 导航菜单项
  • 分类菜单项

控制显示语言

  • URL中的lang参数可以用来为普通用户设置内容语言
  • The cLang param is used by admins to control language of content being edited, eg you can edit articles or navigation in Spanish while still maintaining the Seagull interface in English. 管理员可以使用cLang参数来控制要编辑内容的语言,如你可以在使用英语界面时使用西班牙语编辑文章或菜单。

如果URL中已经有了module/action参数,你可像下面这样调用某种语言:

http://example.com/cms/contentview/lang/zh-TW/

也可像下面这样使用:

http://example.com?lang=zh-TW

SGL_Translation3

SGL_Translation3库负责:

  • 通过检测管理员的偏好,浏览器语言设置,当前域名的国家代码来初始化框架的语言,
  • 初始化内容语言
  • 保存内容字典 - 一个字典是语言键/值对的集合,比如我们有navigation,categories,default字典。

使用范例

//  sets default language for framework, checks for lang param used to set user lang
$trans = SGL_Translation3::singleton('array');
try {
    $trans->loadDefaultDictionaries();
} catch (Exception $e) {
    SGL::raiseError($e->getMessage(), SGL_ERROR_NOFILE);
}
 
modules/cms/i18n.txt · 最后更改: 2010/05/30 00:21 (外部编辑)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2