This is a simple Laravel application that demonstrates how to use Vue i18n for internationalization (i18n) in a Laravel project. The application includes a basic setup for managing translations and switching between different languages. It is based on Laravel 12.14.1 and Vue 3.2.47. It extends laravel breeze starter kit to use Vue 3 with Inertia.js.
This project includes a dev container configuration for Visual Studio Code, which allows you to run the application in a containerized environment. To use the dev container, you need to have the following installed:
I could not test this configuration, since I had already a laravel dev container with the same configuration. I hope this worsk for you.
Run the following command to install the dependencies:
composer install
Then, copy the .env.example
file to .env
and update the database configuration as needed:
cp .env.example .env
Install the bun dependencies:
bun install
Then, run the following command to generate the application key:
php artisan key:generate
Run the following command to create the database tables:
php artisan migrate
Finally, run the following command to start the development server:
composer run dev
This application uses the package laravel-vue-i18n to manage translations. It automatically generates the translation files based on the php files in the /lang
directory, by converting them in json files of the format lang/php_{locale}.json
.
The package offers some methods like trans()
and transChoice()
to translate strings in the application.
There are also commands that generate a ref instead of a string, so you can dinamically change the language in the application.
The Laravel framework is open-sourced software licensed under the MIT license.