This tool is provide management the your language files by dynamical for your Nova application
You can install the package into a Laravel app that uses Nova via composer:
composer install ysfkaya/nova-dynamic-lang
And you need to publish the migration and config files
php artisan vendor:publish --provider="Ysfkaya\NovaDynamicLang\NovaDynamicLangProvider"
You must register the tool with Nova
// in app/Providers/NovaServiceProvider.php
// ...
public function tools()
{
return [
// ...
new \Ysfkaya\NovaDynamicLang\NovaDynamicLang,
);
}
-
file_name :
frontend
We will create a file in your language files to save your fields.
-
default_languages_path :
null
only json fileIf you want to use your languages then set path here. By default available languages will be used.
Example Json Data:
[ { "label": "A language label", "code": "A language code" } ]
Select a store to default fields to save
First Index | Second Index | Third Index |
---|---|---|
Form Input Label | Form Input Value | Short Code for invoke |
Array store is provides you to quickly and simply set up your fields. Only usage the simply rules you can set the fields.
// in config/nova-dynamic-lang.php
// ...
'array' => [
'driver' => 'array',
'fields' => [
// ...
["Title","Title","title"],
["Description","Description","description"]
// ...
],
],
Json store is also like an array store, but only a json file must be defined.
Note : "fields" key is required
// in config/nova-dynamic-lang.php
// ...
'json' => [
'driver' => 'json',
'path' => null // set a json file path,
],
In file :
{
"fields":[
["Title","Title","title"],
["Description","Description","description"]
]
}
Database store is management your fields by dynamical. It allows you use a nova resource. But you shouldn't modify table columns in migration file
// in config/nova-dynamic-lang.php
// ...
'json' => [
'driver' => 'database',
'model' => \Ysfkaya\NovaDynamicLang\Models\LanguageSection::class // or you may use model instance of this model,
],
You can use @lang
blade directive to display text by your app language
@lang('frontend.hello')