- How do I install overtrue/laravel-lang in a Laravel application?
- Install it as a dev or runtime dependency with Composer: composer require overtrue/laravel-lang. The package is a data and distribution package, so there are no service container bindings or middleware to register yourself; it ships a service provider that exposes the language files for publishing. After installing, run php artisan vendor:publish to copy the translations into your application's lang directory. Committing the published files gives you reviewable diffs and full control over overrides.
- Which Laravel versions does overtrue/laravel-lang support?
- Recent releases target modern Laravel versions, and version 6.0.3 explicitly asserts compatibility across Laravel versions. Because the package normalizes its publish target between the older resources/lang layout and the Laravel 9+ root-level lang directory, it is intended to work on both. If you run a mixed fleet of Laravel 8 and Laravel 9+ applications, verify the detection behaviour per app before documenting a single install path.
- Does the package publish to resources/lang or to the lang directory at the project root?
- Laravel 9 moved the default language directory from resources/lang to lang at the project root, and overtrue/laravel-lang follows that change. The 6.0.3 release moved the publish target to the Laravel 9 directory structure, with compatibility handling for older versions. Confirm the detection mechanism in the service provider before assuming one path works everywhere in your estate.
- Will vendor:publish overwrite my existing translation files and custom overrides?
- This is the highest-severity risk with any publish-based language package, because publishing copies files into your repository and can clobber in-house edits to validation, auth, or pagination strings. Run vendor:publish once, commit the results, and treat the published files as first-party source so later syncs happen deliberately through review rather than automatically. If you re-publish on upgrade, check whether a force flag is required and diff the output before merging.
- Does overtrue/laravel-lang ship JSON translation files as well as PHP array files?
- Laravel supports both PHP array files and JSON translation files, and the JSON files are what back the __() helper's string-key fallback chain. The core of this package is the PHP message groups for validation, authentication, passwords, and pagination. Check the package contents for the specific release you install if your application relies on JSON-key translations alongside the PHP files.
- What messages does overtrue/laravel-lang actually translate?
- The package covers Laravel's core framework messages: validation rules, authentication failures, password reset messages, and pagination strings. It provides prebuilt zh-CN translations rather than a translation management system, so it does not change how your application calls __() or the translator. Application-specific copy, such as flash messages and email bodies, still lives in your own language files.
- How do I make Chinese the default locale in Laravel after installing it?
- Set the locale in config/app.php, for example 'locale' => 'zh-CN', or at runtime with App::setLocale('zh-CN'). Because the package targets Laravel's native localization layer, it composes with existing per-request locale resolution and locale-switching middleware without adapter code. Just make sure the published directory matches the locale key you set, since Laravel resolves files by locale folder name.
- Why do some messages still appear in English after a Laravel upgrade?
- Translation corpora are versioned with the package, not with the framework, so a Laravel minor upgrade can introduce new validation rules whose keys are missing from your pinned translation set. Those keys then fall back to English at runtime rather than failing at build time. Re-sync the language files after Laravel upgrades, and add a smoke test that renders common validation messages in zh-CN.
- What license does overtrue/laravel-lang use, and can I commit the files to a private repository?
- The translations are community-contributed and the published files become checked-in source in your application. Review the LICENSE file in the repository and confirm the terms permit redistribution inside proprietary codebases before committing them. If the license is unclear for your use case, keep the files out of source and publish at deploy time instead.
- Is overtrue/laravel-lang actively maintained, and how do I contribute corrections?
- It is a community-maintained translation corpus, so release cadence and maintainer concentration are worth checking before you depend on it heavily. If you need to override strings internally, publish the files and maintain those overrides as first-party source rather than forking. Genuine translation corrections can be proposed upstream via a pull request; otherwise pin a version and document your local patch process.