moderntribe / weglot-companion
Weglot Companion WordPress 插件
Requires
- php: >=7.4
- ext-json: *
- ext-readline: *
- johnbillion/extended-cpts: ^4.0||^5.0
- league/uri: ^6.5
- moderntribe/tribe-libs: ^3.4.13
- spatie/data-transfer-object: ^2.8
Requires (Dev)
- advanced-custom-fields/advanced-custom-fields-pro: *
- codeception/module-asserts: ^1.3
- codeception/module-cli: ^1.1
- codeception/module-db: ^1.1
- codeception/module-filesystem: ^1.0
- codeception/module-phpbrowser: ^1.0
- codeception/module-webdriver: ^1.4
- codeception/util-universalframework: ^1.0
- composer/installers: ^2.0
- johnpbloch/wordpress-core: 5.9.3
- johnpbloch/wordpress-core-installer: 2.0.*
- larapack/dd: ^1.1
- lucatume/function-mocker: ^1.3
- lucatume/wp-browser: ^3.0
- moderntribe/coding-standards: ^3.0
- wpackagist-plugin/weglot: ^3.6
README
为Weglot 翻译插件提供额外功能。
此插件提供了以下功能
- 使用对象缓存进行翻译缓存。
- 为开发者提供更好的翻译过滤器/接口,以便手动翻译 Weglot 无法翻译的内容。
手动翻译 Weglot 错过的内容,例如来自 Ajax 请求返回的 HTML。
必须安装并激活 Weglot 插件才能使用此功能,否则它将静默返回原始内容。
翻译 HTML 字符串
$translated = apply_filters( \Tribe\Weglot\Translate\Translate_Subscriber::FILTER, '<p>Some kind of HTML content</p>' );
翻译 HTML 字符串数组
$translated = apply_filters( \Tribe\Weglot\Translate\Translate_Subscriber::FILTER, [ '<li>some content</li>', '<li>some more content</li>' // etc... ] );
要求
- php7.4+
- docker
- docker-compose v2+
- nvm 或 fnm
- node 16+
- yarn 1.22+
- npm 8.3+
快速入门 首次运行
- 安装 SquareOne Docker (so)
- 运行:
nvm use
- 运行:
yarn install
- 运行:
yarn mix
- 运行:
so bootstrap
- 在 WordPress 控制面板中激活插件并开始开发!
拉取请求 / 构建
确保在提交 PR 之前运行 nvm use
和 yarn prod
并提交 resources/dist
文件夹,以便插件包含最新的前端生产构建。
前端
前端构建由 Laravel Mix 提供支持。
安装
nvm use; yarn install
用法
运行一次: nvm use
然后...
为开发构建
yarn dev
监视文件更改
yarn watch
轮询文件更改
yarn watch-poll
使用热模块替换监视
yarn hot
为生产构建
yarn prod
查看更多选项: yarn mix --help
安装此插件
Composer
如果您正在使用我们的 SquareOne 框架 与 Tribe Libs v3.4+,您可能只需创建一个版本,然后通过 composer require 插件即可。但是,如果这导致 composer 冲突而无法解决,请使用下面的私有 composer 方法。
composer require moderntribe/weglot-companion
私有 Composer 安装程序
每次发布后,都会自动创建一个 weglot-companion.zip
,这是一个完整构建和供应商范围的 WordPress 插件,发布后大约一分钟。要手动安装,请访问发布,然后下载并提取 zip 文件到您的 WordPress 插件文件夹中。
但是,最佳方法是通过使用出色的 ffraenz/private-composer-installer 插件来包含发布 zip 文件。
将自定义存储库添加到项目的 repository
键中的 composer.json
"repositories": [ { "type": "package", "package": { "name": "moderntribe/weglot-companion", "version": "1.0.0", "type": "wordpress-plugin", "dist": { "type": "zip", "url": "https://github.com/moderntribe/weglot-companion/releases/download/{%VERSION}/weglot-companion.zip" }, "require": { "ffraenz/private-composer-installer": "^5.0" } } }, ],
注意:只需更新上面的版本并运行
composer update
即可升级插件。
然后,将插件定义添加到 require 部分
"require": { "moderntribe/weglot-companion": "*", }
通过 extra
部分告诉 composer 将您的 WordPress 插件/主题放在哪里。
注意:根据您的项目调整路径。
"extra": { "wordpress-install-dir": "wp", "installer-paths": { "wp-content/mu-plugins/{$name}": [ "type:wordpress-muplugin" ], "wp-content/plugins/{$name}": [ "type:wordpress-plugin" ], "wp-content/themes/{$name}": [ "type:wordpress-theme" ] } },
您可能还需要在配置中允许此插件
"allow-plugins": { "composer/installers": true, "ffraenz/private-composer-installer": true, }
最后,安装插件
composer update
测试
自动化测试由 wp-browser 和 Codeception 支持。
so test
是指向 codeception cli 的代理命令。
运行所有测试套件
so project:test
或者,运行单个测试套件: unit, integration, functional, webdriver
,例如。
so test run integration
或者,启用调试模式运行
so -- test run integration --debug
鸣谢
许可证
GNU 通用公共许可证 GPLv2(或更新版)。请参阅 许可证文件 了解更多信息。