Translation Files
WNCMS merges your project’s overrides into its core translations. The core wncms-core package exposes a word.php group, and at runtime it will merge your site’s lang/{locale}/custom.php on top of it. You do not need to edit vendor files.
What you should create
Create a custom.php file for each locale you support:
lang/
├── en/
│ └── custom.php
├── zh_TW/
│ └── custom.php
└── ja/
└── custom.phpMinimal example
lang/en/custom.php
<?php
$custom_words = [
'welcome' => 'Welcome to My Site', // override existing key if present
'contact' => 'Get in Touch', // add new key
];
return $custom_words;How the merge works
- WNCMS loads its core
word.php(from thewncms-corepackage). - Then it loads
lang/{locale}/custom.phpfrom your app and merges it. - Keys in
custom.phpoverride same-named keys provided by WNCMS. - New keys in
custom.phpbecome available under the same namespace.
How to reference keys
Recommended (merged group, includes your overrides):
@lang('wncms::word.welcome')
@lang('wncms::word.contact')You can still use the traditional Laravel group if you want to point directly at your file:
@lang('custom.contact')Both methods work; wncms::word.* is preferred because it always reflects the merged result.
Per-locale behavior
Create one custom.php per locale you actually serve:
lang/en/custom.phplang/zh_TW/custom.phplang/ja/custom.php
Only keys present in a locale’s custom.php will override that locale’s text.
Notes
Keep vendor defaults in the package; keep site/theme–specific wording in your
custom.php.Maintain consistent keys across locales to avoid missing translations.
After changing language files in production, clear caches if needed:
php artisan cache:clear php artisan config:clear