Generic translations module for PyroCMS 3.1 and up. This package handles streams translations as well as module translations.
Heads up!: Currently still in Alpha state. It works, but there are no automated tests yet, and the package is still subject to code review & refactor.
-
composer require bitsoflove/translations-module
-
php artisan module:install translations
-
navigate to the
config/app.php
providers array. Replace Laravel's defaultTranslationServiceProvider
with theTranslatorServiceProvider
from this package.\Bitsoflove\TranslationsModule\Translator\TranslatorServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
You might still have to run the build script
cd core/bitsoflove/translations-module && npm install && npm run dist
First, you'll have to publish the config file:
php artisan addon:publish bitsoflove.module.translations
By default, after installing this module, every admin will be able to translate all streams and all modules. To allow only a subset of that list, update the published config file accordingly:
<?php return [
'middleware' => [
// list any middlewares you want to use here
// you can use middleware to manipulate this config before the page gets rendered
//TranslationsModuleMiddleware::class,
],
'modules' => [
/**
* Possible values:
*
* 'all' or an array of Anomaly\Streams\Platform\Addon\Module classes
*/
'allowed' => [
[
'module' => \Anomaly\PagesModule\PagesModule::class,
'default' => true,
],
[
'module' => \Anomaly\PostsModule\PostsModule::class,
'default' => false,
],
]
],
'streams' => [
/**
* Possible values:
*
* 'all' or an array of EntryModel classes
*/
'models' => [
[
'model' => YourModel::class,
'fields' => ['title'], // just allow translation of the title field
'default' => true,
],
[
'model' => YourSecondModel::class,
'fields' => [], // all fields
'default' => false,
],
],
'locales' => [
'default' => config('streams::locales.default'),
'supported' => array_keys(
config('streams::locales.supported')
),
],
]
];
- Instead of using
composer require
, manually add the following entry to the composer 'require' list:"bitsoflove/translations-module": "dev-master"
- Add this repository to the composer repositories list (to ensure you'll fetch the repo)
"repositories": [
{
"url": "https://github.com/bitsoflove/pyro_translations-module.git",
"type": "git"
}
],
Then:
composer install
php artisan module:install translations
cd core/bitsoflove/translations-module
cp .env.example.js .env.js
- Change the proxy property in
.env.js
to the host of your local pyro application npm install
npm run dev
0.0.1
Reusable proof of conceptSupports middlewareSupports file translations (overwritesLang::get()
andtrans()
using extendedTranslator
)
0.0.2
- code review & refactor
- performance updates
- add autosave option
- ui updates (loader, general styling)
0.0.3 till 0.1.0
- support laravel
fallback
andreplace
options - ensure all dist assets are both in the repo and up to date
- google auto translate
- view entry (streams)
- tests
Under consideration
- revisions
- add default seeder