wirelab/language_switcher-plugin

此包已被废弃且不再维护。未建议替代包。

提供多种语言切换方式的插件。

安装次数: 4,443

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 4

开放问题: 0

类型:streams-addon

1.3 2017-11-28 18:41 UTC

This package is not auto-updated.

Last update: 2021-02-20 08:54:34 UTC


README

⚠️ 此仓库已被弃用 ⚠️

为用户提供多种语言切换方式的 PyroCMS 3 插件。默认类型使用 bootstrap 3。

安装

composer require wirelab/language_switcher-plugin

使用

在所需的 twig 文件中调用 {{ languageSwitcher($type, $options) }}
例如 {{ languageSwitcher('dropdown', {'toggle_title':'选择语言'}) }}

字符串 $type

默认类型是 dropdownmodalli。使用 modal 类型时,请确保在加载 jQuery 后调用。

默认类型

Li

68747470733a2f2f776972656c61622e6769746875622e696f2f696d616765732f6c616e67756167655f73776974636865722d706c7567696e2f6c692e706e67

下拉菜单

68747470733a2f2f776972656c61622e6769746875622e696f2f696d616765732f6c616e67756167655f73776974636865722d706c7567696e2f64726f70646f776e2e706e67

模态框

模态框关闭时会创建一个 cookie。

68747470733a2f2f776972656c61622e6769746875622e696f2f696d616765732f6c616e67756167655f73776974636865722d706c7567696e2f6d6f64616c2e706e67

创建新类型

可以通过在 <插件路径>/resources/views/ 下添加视图来创建新类型。创建新视图时,它将自动将其添加为类型。

以下变量传递给所有视图
container.class
toggle.class
ul.class
li.class
a.class

toggle.title

locales 所有可用区域设置数组,格式如:[[url => locale],[url => locale]]

当前变量包含有关当前正在使用的区域设置的数据
current.locale
current.country
current.language

偏好变量包含有关用户的数据
prefered.locale
prefered.enabled 检查用户语言是否可用/启用。
prefered.url 用户区域设置的当前页面 URL。
prefered.country
prefered.language

数组 $options (可选)

$options 数组接受以下选项
container_class
toggle_class
toggle_title 当未提供标题时,将使用当前区域设置。
ul_class
li_class
a_class
pecl 退出使用 PECL (将删除一些功能)