PHP code example of upon / mlang

1. Go to this page and download the library: Download upon/mlang 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/ */

    

upon / mlang example snippets


composer 

composer 

php artisan vendor:publish --tag="mlang"

// ...
'models' => [
    \App\Models\Category::class,
    \App\Models\Product::class,
    // ...
]
// ...


// ...
use Upon\Mlang\Models\MlangModel;

class Category extends MlangModel
{
    // ...

php artisan mlang:generate

/** Replace {model} with the desired model you need 
 * (e.g., category or in subdirectory dir\\Category).
 * This using the default model path [App\\Models]
 * you can update the model path in the config file.  
 */
php artisan mlang:generate {model}

/** 
 * all to run all models or specify one model name (e.g., Sub\\Category).
 * Replace {locale} with the desired language code (e.g., en for English).
 */
php artisan mlang:generate {model|all} {locale}

/**
 * Replace {locale} with the desired language code (e.g., en for English).
 * Replace {table} with the desired table name (e.g., categories).  
 */
php artisan mlang:remove {table} {locale}

 protected $middlewareGroups = [
'web' => [
// ...
\Upon\Mlang\Middleware\DetectUserLanguageMiddleware::class,
],

    // ...
];

/** Replace {locale} with the desired language code. */
app()->setLocale('{locale}');

    Model::trFind(1);

    /** This will get a collection based on the current language*/
    Model::trWhere(['name' => 'test'])->get();
shell
    php artisan mlang:migrate