name: laravel-lang-sync-inertia description: "Activate when the user is adding, debugging, or documenting Laravel to Inertia translation syncing with erag/laravel-lang-sync-inertia. Use for syncLangFiles(), Lang facade usage, shared Inertia lang props, generated frontend JSON translations, config/inertia-lang.php, package install or generate commands, Vue, React, or Svelte frontend lang() helpers, pluralization helpers, and locale-aware loading." license: MIT metadata: author: Er Amit Gupta
Laravel Lang Sync Inertia
Use this skill when a Laravel task involves erag/laravel-lang-sync-inertia.
Documentation
Use search-docs first when it is available for Laravel and Inertia integration details. For package-specific behavior, inspect:
src/LangSyncInertiaServiceProvider.phpsrc/Support/TranslationLoader.phpsrc/LangHelpers.phpsrc/Middleware/ShareLangTranslations.phpsrc/Commands/InstallLangCommand.phpsrc/Commands/GenerateLangCommand.phpconfig/inertia-lang.phpreferences/api.mdreferences/package.mdreferences/examples.md
Load only the reference file you need:
references/api.mdfor helper, facade, config, command, and shared-prop API detailsreferences/package.mdfor package surface and behavior rulesreferences/examples.mdfor Laravel, Vue, React, and JSON export examples
Core Working Pattern
- Install the backend package and the frontend helper package.
- Publish Laravel language files with
php artisan lang:publishwhen the app does not already have them. - Publish the package config with
php artisan erag:install-lang. - Choose one loading strategy:
- call
syncLangFiles()inside the controller action before returningInertia::render(...), or - run
php artisan erag:generate-langto generate JSON translation files for the configured output path
- call
- Read translations directly inside each Vue, React, or Svelte page/component with
lang()from@erag/lang-sync-inertia/vue,@erag/lang-sync-inertia/react, or@erag/lang-sync-inertia/svelte.
Important Behavior
syncLangFiles(string|array $fileName)loads one or many Laravel translation groups for the current locale.- The package shares translations under the
langInertia prop. TranslationLoaderreads fromconfig('inertia-lang.lang_path')and caches loaded groups in memory for the request.LangSyncInertiaServiceProviderautomatically loads generated JSON files fromconfig('inertia-lang.output_lang')/{locale}/*.json.- After
php artisan erag:generate-lang, you do not add any extra app code for JSON loading. The package reads all generated JSON files for the current locale during the normal Inertia share flow inLangSyncInertiaServiceProvider. - When generated JSON files are present, the package auto-loads all generated translation groups for the current locale. You do not need to call
syncLangFiles()for those generated groups. - Generated JSON translations are merged first and runtime-loaded translations win on conflicts through
array_replace_recursive. - The current locale comes from
app()->getLocale(). - Vue, React, and Svelte consumers should prefer the dedicated entrypoints:
@erag/lang-sync-inertia/vue@erag/lang-sync-inertia/react@erag/lang-sync-inertia/svelte
- Do not configure this package in Vite,
app.ts, orapp.js. - Do not register an Inertia app plugin/provider for frontend translation helpers.
- Import
lang()in the page or component that needs translations. - Frontend helpers support:
__()trans()transChoice()trans_choice()
Configuration
Key config values in config/inertia-lang.php:
lang_path: where backend PHP translation files are read fromoutput_lang: whereerag:generate-langwrites frontend JSON output
Prefer changing these config values instead of rewriting the package loader behavior.
Verification
For package work, validate the affected flow directly:
- installation and publish flow
- controller-side
syncLangFiles()usage - locale-aware loading from the configured language directory
- generated JSON merge behavior
- frontend helper usage in Vue or React
When editing the package itself, also review the generated diff for resources/boost/skills/lang-sync-inertia/* so the skill stays concise and references stay load-on-demand.
Common Pitfalls
- Calling
syncLangFiles()after returning the Inertia response - Expecting translations to appear in Blade views instead of Inertia props
- Forgetting
php artisan lang:publishin apps that do not yet havelang/{locale}files - Importing from the root frontend package for new code instead of
/vue,/react, or/svelte - Changing config paths without updating deployment or build steps that rely on generated JSON