Git Product home page Git Product logo

nova-language-switch's Introduction

A Laravel Nova Tool to add language switcher to your application

This Nova tool lets you:

  • Add a Language switcher to the header of the nova application.
  • Handle Switch language and put the current locale to Laravel cache to remember language from multiple browsers.
  • Switch the direction of the application based on the RTL-supported application written in config.

Requirements

  • php: >=8.0

  • laravel/nova: ^4.0

     Note: This package dose't work with nova 3
    

Features

  • Add multiple languages from the config.
  • Remember set local based on cache no need to save in the database table
  • Auto inject to the header of the application
  • Just 4 steps to setup

Screenshot

|enter image description here |enter image description here |

Installation

You can install the nova tool in to a Laravel app that uses Nova via composer:

composer require badinansoft/nova-language-switch

Next up, you must register the tool with Nova. This is typically done in the tools method of the NovaServiceProvider.

// in app/Providers/NovaServiceProvider.php

// ...

public function tools()
{
    return [
        // ...
        new \Badinansoft\LanguageSwitch\LanguageSwitch(),
    ];
}

Next up, must you publish the config file with for add your languages:

php artisan vendor:publish --provider="Badinansoft\LanguageSwitch\ToolServiceProvider" --tag="config"

This is the contents of the published config file:

<?php  
  
return [  
  
	/**  
	 * List of languages that your application supports 
	 * array <string,  string>  
	 */  
	 'supported-languages' => [  
		  'en' => 'English',  
		  'ar' => 'Arabic',  
		  //here you can add new lanaguage or remove language that you need by 'local'=>'Label'
	 ],  
  
	/**  
	 * Languages That need RTL support 
	 *  string 
	 * */  
	'rtl-languages' => [  
		  'ar'  
		  //here put that language that need support RTL just put local of the language like this example for arabic 
		 
	 ],  
  
];

Finally you should register middleware This is typically done in the $middlewareGroups property of the Http/Kernel in web group.

   /**  
   *  The application's route middleware groups. 
   *  @var array<string, array<int, class-string|string>>  
   */  
   protected $middlewareGroups = [  
     'web' => [  
   		  //...
   		  \Badinansoft\LanguageSwitch\Http\Middleware\LanguageSwitch::class  
     ],
     //...
   ];

Credits

License

The MIT License (MIT). Please see License File for more information.

nova-language-switch's People

Contributors

badinansoft avatar elsayed85 avatar shahabzebare avatar veneliniliev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.