Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.
/ nova-dynamic-lang Public archive

This tool is provide management the your language files by dynamical

License

Notifications You must be signed in to change notification settings

ysfkaya/nova-dynamic-lang

Repository files navigation

Laravel Nova Dynamic Language

This tool is provide management the your language files by dynamical for your Nova application

Dashboard index page

Installation

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,
    );
}

Configuration

  • file_name : frontend

    We will create a file in your language files to save your fields.

  • default_languages_path : null only json file

    If 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

Rules (For Store : array,json)
First Index Second Index Third Index
Form Input Label Form Input Value Short Code for invoke

Array store

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

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

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,
],

Usage

You can use @lang blade directive to display text by your app language

@lang('frontend.hello')

About

This tool is provide management the your language files by dynamical

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published