PHP code example of centrust / nova-localization

1. Go to this page and download the library: Download centrust/nova-localization library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

centrust / nova-localization example snippets


  Text::make(_tran('Name'), 'name'),
  Text::make(_tran('Description'), 'description')

return [
  /** 
     * If set to true, this will enable caching for localization. The actual value for this translation is taken from the server's cache.
     * If the LOCALIZATION_ENABLE_CACHE environment variable does not exist, the default value will be false.
     * This is useful for improving the application's performance by caching localizations,
     * but it might delay the appearance of any changes made to localization files until the cache is refreshed.
     **/
    'localization_enable_cache' => env('LOCALIZATION_ENABLE_CACHE', false),
    
    /**
     * This URL is for loading the Arabic font from Google Fonts.
     * This font is needed for Arabic language support in your application.
     **/
    'ar_google_font_url'=> 'https://fonts.googleapis.com/css2?family=Scheherazade+New:wght@700&display=swap',


    /**
     * This is the path to the CSS file that contains the Arabic font family.   
     * example : 'css/rtl-ar.css'
     * The file must be in the public folder.
     * This font is needed for Arabic language support in your application.
     */
    'ar_font_family_css'=> 'css/rtl-ar.css',

];


_tran('This is a label');



use Centrust\NovaLocalization\Nova\NovaLocalizationResource;

class Localization extends NovaLocalizationResource
{

}


  Nova::userMenu(function (Request $request, Menu $menu) {

            $language = app()->getLocale() == 'ar' ? 'en' : 'ar';

            $menu->append(MenuItem::externalLink(app()->getLocale() == 'ar' ? 'English' : 'عربي', '/change-language/' . $language . '/' . $request->user()->id));


            return $menu;
        });


bash
php artisan vendor:publish --tag="nova-localization-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="nova-localization-config"