moderntribe / weglot-companion
Weglot Companion WordPress Plugin
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 13
Forks: 0
Open Issues: 0
Type:wordpress-plugin
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
Provides additional functionality for the Weglot Translate Plugin.
This plugin makes available the following features:
- Translation caching using object caching.
- Better translate filters/interfaces for developer use to translate content manually that Weglot is unable to translate.
Manually translate content that Weglot misses, like HTML returned from an Ajax request.
The Weglot plugin must be installed and activated for this to work, otherwise it will just silently return the original content.
Translate an HTML string
$translated = apply_filters( \Tribe\Weglot\Translate\Translate_Subscriber::FILTER, '<p>Some kind of HTML content</p>' );
Translate an array of HTML strings
$translated = apply_filters( \Tribe\Weglot\Translate\Translate_Subscriber::FILTER, [ '<li>some content</li>', '<li>some more content</li>' // etc... ] );
Requirements
- php7.4+
- docker
- docker-compose v2+
- nvm or fnm
- node 16+
- yarn 1.22+
- npm 8.3+
Quick Start First Run
- Install SquareOne Docker (so)
- Run:
nvm use
- Run:
yarn install
- Run:
yarn mix
- Run:
so bootstrap
- Activate your plugin(s) in the WordPress dashboard and start developing!
Pull Requests / Building
Ensure you run nvm use
and yarn prod
and commit the resources/dist
folder before submitting a PR, so the plugin includes the latest front-end production build.
Front end
Front end building is powered by Laravel Mix.
Installation
nvm use; yarn install
Usage
Run once: nvm use
and then...
Build for development:
yarn dev
Watch for file changes:
yarn watch
Poll for file changes:
yarn watch-poll
Watch with hot module replacement:
yarn hot
Build for production:
yarn prod
See more options: yarn mix --help
Installing this plugin
Composer
If you're using our SquareOne Framework with Tribe Libs v3.4+ you can likely just create a release and composer require the plugin. However, if this results in composer conflicts that can't be resolved, use the private composer method below.
composer require moderntribe/weglot-companion
Private Composer Installer
Every published release automatically creates a weglot-companion.zip
which is a fully built and vendor scoped WordPress plugin, about a minute after the release is published. To manually install, visit a release and download and extract the zip in your WordPress plugins folder.
However, the best way to include the release zip is by using the fantastic ffraenz/private-composer-installer plugin.
Add a custom repository to your project's repository
key in 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" } } }, ],
NOTE: Simply update the version above and run
composer update
to upgrade the plugin in the future.
Then, add the plugin definition to the require section:
"require": { "moderntribe/weglot-companion": "*", }
Tell composer where to put your WordPress plugins/themes via the extra
section.
NOTE: Adjust the paths based on your project.
"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" ] } },
You may have to allow this plugin in your config as well:
"allow-plugins": { "composer/installers": true, "ffraenz/private-composer-installer": true, }
Finally, install the plugin:
composer update
Tests
Automated testing is powered by wp-browser and Codeception.
so test
is a proxy command for the codeception cli.
Run all test suites:
so project:test
Or, run an individual test suite: unit, integration, functional, webdriver
, e.g.
so test run integration
Or, run with debugging enabled:
so -- test run integration --debug
Credits
- Based on Spatie Skeleton
License
GNU General Public License GPLv2 (or later). Please see License File for more information.