PHP code example of mgcodeur / laravel-translation-loader
1. Go to this page and download the library: Download mgcodeur/laravel-translation-loader 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/ */
mgcodeur / laravel-translation-loader example snippets
use Mgcodeur\LaravelTranslationLoader\Translations\TranslationMigration;
return new class extends TranslationMigration
{
public function up(): void
{
$this->add('en', 'welcome.title', 'Welcome to Our App');
$this->add('fr', 'welcome.title', 'Bienvenue dans notre application');
$this->add('es', 'welcome.title', 'Bienvenido a nuestra aplicación');
}
public function down(): void
{
$this->delete('en', 'welcome.title');
$this->delete('fr', 'welcome.title');
$this->delete('es', 'welcome.title');
// or you can just do: $this->deleteAll('welcome.title');
// $this->deleteAll('key1', 'key2', 'key3');
}
};
// In controllers, views, or anywhere
echo __('welcome.title'); // Outputs: "Welcome to Our App" (if en is active)