TL;DR
- Fixes #771 -- on a brand-new install, MegaBasterd now autodetects the OS language and starts up in that locale instead of always defaulting to English. Existing installs are unaffected: anyone who has launched 8.27 or later already has settings rows persisted, so the autodetect path is skipped on upgrade. No popup, no restart prompt -- the GUI is built directly in the detected language.
- Detection covers the eight currently bundled locales (EN/ES/IT/TR/ZH/VI/DE/HU). Any other OS locale falls back to English, same as today.
New in 8.51
#771 -- First-run OS language autodetection
-
What changed. On a true first run -- the SQLite
settingstable has zero rows immediately aftersetupSqliteTables()-- a new block in theMainPanelconstructor readsLocale.getDefault().getLanguage(), maps the ISO 639-1 code to MegaBasterd's internal language code (es->ES,it->IT,tr->TU,zh->CH,vi->VI,de->GE,hu->HU,en->EN) and writes the result aslanguage=XXinto the settings table. The downstreamloadUserSettings()reads that row through the normal lookup path, so whenLabelTranslatorSingletoninitialises andMainPanelViewbuilds, the locale is already correct and the very first paint comes out localised. Locales with no bundled translation fall back toEN. -
Why not in
loadUserSettings(). That was the obvious place but it does not work: by the timeloadUserSettings()runs (line 413 of the constructor), the v8.27verify_down_file_migrated_v827migration block has already inserted a row, so any "is the settings table empty?" check would return false on a real first run. The autodetect block is therefore positioned betweensetupSqliteTables()and the v8.27 migration -- the only window when an empty table is still observable. -
No regression for existing users. Anyone who has launched 8.27 or later has
verify_down_file_migrated_v827=yesin their settings table, soisSettingsTableEmpty()returns false and the autodetect is skipped.loadUserSettings()then resolves the language as before: explicit value if the user had chosen one, otherwiseDEFAULT_LANGUAGE="EN". -
No popup, no restart. The detection runs before
_view = new MainPanelView(this)and before the firstLabelTranslatorSingleton.getInstance()call, so the locale is set on the very first label lookup. Users only need a restart when changing language after the GUI is already built (i.e. from the Settings dialog), which is the existing behaviour.
Other
- Version bumped to 8.51 in
pom.xmlandMainPanel.VERSION. - New helper
DBTools.isSettingsTableEmpty()-- a singleSELECT 1 FROM settings LIMIT 1under the samesynchronized/SqliteSingletonpattern as the rest ofDBTools; returnsfalseonSQLExceptionso the safe "not a first run" path wins.