arthedain / translation
A Laravel Nova Translation tool.
Installs: 188
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:Vue
Requires
- php: >=7.1.0
README
composer require arthedain/translation
Then include in NovaServiceProvider
public function tools()
{
return [
new Translation,
];
}
Publish migrations
php artisan vendor:publish --provider="Arthedain\Translation\TranslationServiceProvider" --tag="migration"
In migration you can change or add fields except
custom_properties
field
Publish model
php artisan vendor:publish --provider="Arthedain\Translation\TranslationServiceProvider" --tag="model"
Publish config
php artisan vendor:publish --provider="Arthedain\Translation\TranslationServiceProvider" --tag="config"
Publish editor skin
php artisan vendor:publish --provider="Arthedain\Translation\TranslationServiceProvider" --tag="tinymce"
How to use
\App\Models\Translation::locale('some text to add in db', ['tab' => 'All', 'editor' => false, 'key' => false]);
tab
optinal string parameter, create group of fields. The default isAll
The value of the tab
parameter can be changed in the localization file
"All": "Все"
editor
optinal boolean parameter, sets to use a visual editor or not
For calling method from trait in view use autoload, or other method
// composer.json
"autoload": {
"files": [
//path to file
],
},
// file
<?
function locale(string $name, array $parameters = []): string{
return \App\Models\Translation::locale($name, $parameters);
}
// view
{{ locale('some text', ['tab' => 'Index']) }}
Resource field
In resource call
use Arthedain\Translation\TranslationField;
//
TranslationField::make('Translations')->tabName('Index'),
Localization
Go to /lang/vendor/nova/en.json
"Translation": "Translation", "Update": "Update", "Translations updated successfully": "Переводы успешно обновлены", "Show default value": "Show default value", "Show delete button": "Show delete button", "Saved successfully": "Saved successfully", "Deleted successfully": "Deleted successfully", "Error": "Error",