Configuration
Mona loads default settings automatically. Publish the files you need to customize into your application's config/ directory.
php artisan vendor:publish --tag=localization_main
The localization tag publishes all five files. Each filename without .php is also a publication tag and a Laravel configuration key.
| File | Settings |
|---|---|
localization_main.php | Translation styles, aliases, and publication filters |
localization_punctuation.php | Smart punctuation and locale-specific quote marks |
localization_routes.php | Route names, locale sources, and middleware |
localization_models.php | Translation model suffix, filtering, and generator paths |
localization_map.php | Locale metadata such as script, region, and direction |
After changing configuration, clear the config cache. Run php artisan lang:update to regenerate translations affected by publication settings.
Translation styles
A translation style is a named dictionary that changes the wording of selected phrases. For example, a pack can provide informal.json for a friendly tone or john.json for wording used by a product. Style names are independent of locale codes, application names, and package names. Any translation pack can provide a style under locales/<locale>/<style>.json for the languages it covers. A style can contain as few as one phrase. The original use case was informal forms of address. Informal translations discussion
After you install a plugin that provides john, put it last in config/localization_main.php to give it priority within each dictionary source.
'styles' => ['default', 'informal', 'john'],
When you run php artisan lang:update, Publisher merges the style files for each installed locale. For each phrase, john wins if it supplies the phrase, followed by informal and then default. For example, a French pack can override one phrase in locales/fr/john.json, while German uses locales/de/informal.json or locales/de/default.json for that same phrase. Publisher applies the order separately to the shared Library and the pack contributing the file. For that file, a matching phrase from the pack takes precedence over the Library's entry.
The default setting is ['default', 'inline']. The inline style provides generic validation messages such as “This field must be accepted.” Set styles to ['default'] to use standard wording only. If you omit default from the list, Publisher adds it at the beginning.
Locale aliases
Set localization_main.aliases as a map from canonical codes to aliases. For example, add the following entry to the returned array in config/localization_main.php.
'aliases' => [
'de_CH' => 'de-CH',
],
Artisan can accept de-CH, while Laravel and published files use de_CH. Set APP_LOCALE and APP_FALLBACK_LOCALE to canonical codes. See Locales and names for conversion and lookup examples.
Skip files and force integrations
localization_main.skipmatches case-insensitive*patterns against full paths with/separators. It can exclude source files, dictionaries, and publication targets. For example,['*/lang/fr/validation.php']keeps the Publisher from writing that target in an application usinglang/.localization_main.forceaccepts Composer package names. It lets the Publisher use manifest entries even if the named dependency is absent, the installed version does not match, or the root project name differs. Use it when the manifest's translations are applicable to your application.
skip takes precedence over force.
Smart punctuation
Set LOCALIZATION_PUNCTUATION_ENABLED=true to enable typographic quotes, dashes, and ellipses in published translations. Edit localization_punctuation.common for general rules and localization_punctuation.locales for overrides keyed by canonical locale code. Published strings take on these rules the next time the Publisher writes them.