-
Notifications
You must be signed in to change notification settings - Fork 0
Adding a New Language
This page describes everything that has to happen for a new language to work end-to-end - based on what was actually needed when Spanish (es) was added. Use it as a checklist for any future language.
Copy an existing file (resources/lang/en/all.php or resources/lang/hu/all.php) into a new folder, e.g. resources/lang/es/all.php, and translate every value - keep every key exactly the same, only the strings change.
No separate registration step is needed. UsersController builds the language-switcher list dynamically:
$languages = array_diff(scandir(resource_path('lang')), ['..', '.']);As soon as the folder exists with a properly filled all.php, the new language automatically appears in My Settings.
This is a separate file from step 1, and easy to forget. DatabaseSeeder picks which one to run based on the APP_LANGUAGE env value:
database_path("seeders/lang/{$mainLanguage}.php")This file must exist with the same top-level array keys as en.php/hu.php: intervention_templates, console_scripts, ws_filters, notifications, global_settings, downloads, documents, service_updates.
Important: the documents array should list all language variants of the installation/user guides, not just the new one - this is what makes a fresh install always seed every language's documentation regardless of which APP_LOCALE was chosen during setup. Keep this array identical across en.php, hu.php, and the new language's file.
These were real bugs found when Spanish was added as the third language - both are now fixed to be language-agnostic, so a fourth language shouldn't need any code changes here. Still worth checking if either regresses:
-
RegisterController::store()- originally never set a new user'slanguagefield at all (alwaysnull, silently falling back toAPP_FALLBACK_LOCALE). Fixed to$user->language = config('app.locale'); -
UsersController::switchLanguage()- originally a hardcodedswitchthat only accepted"hu"/"en", silently nulling out anything else. Fixed to check against the samescandir(resource_path('lang'))list used by the settings page, so it now accepts whatever languages actually exist.
The installer's language prompt has its own small, hardcoded allow-list that needs updating for each new language:
LOCALE_CHOICE=$(ask "Default language (hu/en/es)" "en")
case "${LOCALE_CHOICE}" in
hu|es) ;;
*) LOCALE_CHOICE="en" ;;
esacAdd the new code to both the prompt text and the case pattern (e.g. hu|es|de) ;;), otherwise the script will silently fall back to en for the new language.
Three documents need a full translation, matching the structure/formatting of the existing