rene-roscher/laravel-i18n-json-converter
| Install | |
|---|---|
composer require rene-roscher/laravel-i18n-json-converter |
|
| Latest Version: | 1.0.2 |
| PHP: | >=8.2 |
| Laravel: | 10 · 11 · 12 |
| License: | MIT |
| Last Updated: | Jun 22, 2026 |
| Links: | GitHub · Packagist |

A Package for Laravel that converts PHP array-based translation files into flattened JSON files, making them compatible with e.g. xiCO2k/laravel-vue-i18n
A Package for Laravel that converts PHP array-based translation files into flattened JSON files, making them compatible with xiCO2k/laravel-vue-i18n.
Installation
You can install the package via composer:
composer require rene-roscher/laravel-i18n-json-converter
You can convert your PHP array-based translation files into flattened JSON files by running the following command:
php artisan i18n:convert
Configure i18n for vue-i18n
import { i18nVue } from 'laravel-vue-i18n'
// Register the i18n plugin like this
// Tested with Vue 3 (Inertia) and Vite 4
// You need to add the locales manually to the switch, dynamic loading is not supported yet
app.use(i18nVue, {
resolve: async (lang) => {
const langFiles = import.meta.glob('../lang/*.json', { eager: true })
let modules
switch (lang) {
case 'en':
modules = import.meta.glob('../lang/json/en/*.json', { eager: true })
break
case 'de':
modules = import.meta.glob('../lang/json/de/*.json', { eager: true })
break
}
const messages = langFiles[`../lang/${lang}.json`] || {}
for (const path in modules) {
const regex = new RegExp(`../lang/json/${lang}/(.+)\\.json$`)
const match = path.match(regex)
if (match) {
const prefix = match[1]
const moduleMessages = modules[path].default
for (const key in moduleMessages) {
messages.default[`${prefix}.${key}`] = moduleMessages[key]
}
}
}
return messages
}
})
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
Related Packages
A full featured menu-builder with the integration of the spatie permission packa...
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.0.2 | >=8.2 | ^10.0|| | MIT | |
| 1.0.1 | >=8.2 | ^10.0|| | MIT | |
| 1.0.0 | ^8.4 | ^10.0|| | MIT |