开放平台
首页
我的应用
我的分销
开发文档
技术社区
魔方加密
WitFrame
注册
登录
资料设置
消息提醒
财务管理
密码安全
身份认证
退出
模板和语言包
<div class="tbmu bbda mbm"><a href="?ac=document&page=dev_plugin">准备工作</a> <span class="pipe">|</span> <a href="?ac=document&page=plugin_module">插件接口</a> <span class="pipe">|</span> <a href="?ac=document&page=plugin_vars">参数读取</a> <span class="pipe">|</span> <a href="?ac=document&page=plugin_hook">页面嵌入</a> <span class="pipe">|</span> <a href="?ac=document&page=plugin_specialthread">特殊主题</a> <span class="pipe">|</span> <a href="?ac=document&page=plugin_classes">第三方拓展类</a> <span class="pipe">|</span> <a href="?ac=document&page=plugin_other_module">其它模块</a><br><a href="?ac=document&page=plugin_install">安装脚本</a> <span class="pipe">|</span> <a href="?ac=document&page=plugin_language" class="a">模板和语言包</a> <span class="pipe">|</span> <a href="?ac=document&page=plugin_notice">注意事项</a></div> [TOCM] ## 插件语言包 ### 创建语言包 给插件创建语言包首先需要创建一个 data/plugindata/identifier.lang.php 文件,文件内容中包含 4 个数组,如下: <?php $scriptlang['identifier'] = array( 'english' => 'chinese', ... ); $templatelang['identifier'] = array( 'english' => 'chinese', ... ); $installlang['identifier'] = array( 'english' => 'chinese', ... ); $systemlang['identifier'] = array( 'file' => array( 'english' => 'chinese', ... ), ... ); ?> - $scriptlang 为程序脚本文件的语言包。 - $templatelang 为模版文件的语言包。 - $installlang 为安装、升级、卸载脚本用的语言包。 - $systemlang 为系统语言包(Discuz! X3 新增)。 - 如果插件不涉及某些类型的语言文字,变量可忽略。 然后在插件基本设置中开启语言包选项后即可。 ### 调用语言包 模版中调用模板文件语言包,通过 {lang identifier:english} 方式调用。 程序脚本中调用脚本文件语言包,通过 lang('plugin/identifier', 'english') 方式调用。 安装脚本中调用安装脚本文件语言包,通过 $installlang 变量直接获取。如 $installlang['english']。 系统语言包用于替换系统语言包中的某些语言条目。 ### 语言包导出 创建好的语言包在插件导出后会自动导出到 XML 文件中,供插件作者转码后发放多编码版本的插件。如上例中导出的 XML 中会包含以下内容: <item id="language"> <item id="scriptlang"> <item id="english"><![CDATA[chinese]]></item> </item> <item id="templatelang"> <item id="english"><![CDATA[chinese]]></item> </item> <item id="installlang"> <item id="english"><![CDATA[chinese]]></item> </item> <item id="systemlang"> <item id="file"> <item id="english"><![CDATA[chinese]]></item> </item> </item> </item> > data/plugindata/identifier.lang.php 文件不必在插件发布的时候导出,此文件仅供插件设计者模式时使用。 ## 插件模板 插件的模板统一放置到 source/plugin/identifier/template 目录下,程序脚本通过以下语句调用插件模板文件,如下例,调用 source/plugin/identifier/template/test include template('identifier:test'); 模版中调用插件模版通过以下方法: {template identifier:test} 模板的编写详见:[模板创建、解析原理详解](?ac=document&page=dev_template) <p class="xg1" align="right">更新时间:2013-1-28</p>
开发文档
平台介绍
技术文档