ippey / weglot-integration

WEGLOT集成

安装: 6

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 3

分支: 0

开放问题: 4

类型:craft-plugin

0.2.0 2021-01-04 03:12 UTC

README

Weglot集成

要求

此插件需要Craft CMS 3.0.0-beta.23或更高版本。您还需要Weglot账户

安装

要安装此插件,请按照以下说明操作。

  1. 打开您的终端并转到Craft项目目录

     cd /path/to/project
    
  2. 然后告诉Composer加载插件

     composer require Ippey/weglot-integration
    
  3. 在控制面板中,转到设置 → 插件,然后点击“安装”按钮以安装weglot-integration。

weglot-integration概述

此插件通过Weglot提供轻松切换语言的功能。Weglot会自动翻译,而不是您手动操作。

weglot

配置

您需要从Weglot仪表板获取API密钥,并在设置页面保存它。此插件使用“JavaScript集成”。当您设置Weglot项目时,请点击“使用JavaScript集成”。

如何使用

Twig扩展

自动翻译

更新 您不需要使用Twig过滤器。此插件会自动添加script标签。

您可以在页面右下角看到语言切换器。如果您切换到其他语言,页面将自动翻译。

手动翻译

如果您想手动翻译,请使用以下Twig过滤器。

{{ '攻殻機動隊' | weglot_translate('ja', 'en') }}
Ghost in the Shell.

服务

您也可以在PHP代码中使用插件的服务进行翻译。

$text = 'Spirited Away';
$from = 'en';
$to = 'ja';
$translated = \ippey\weglotintegration\Weglotintegration::getInstance()->weglotService->translate($text, $from, $to);
echo ($translated); // 千と千尋の神隠し