SMAPI ignores the existence of en.json and en-EN.json in i18n folders
Spiderbuttons opened this issue ยท 0 comments
SMAPI will not correctly use an en.json
or en-EN.json
file as it should for i18n. It should prioritize the latter, then the former, and then finally default.json
, but specifically for English, it will only utilize default.json
and ignore the other two. The issue happens in Translator:GetRelevantLocales and more upstream in one of BaseContentManager's two GetLocale functions. The overloaded GetLocale function grabs the language string from Stardew Valley itself, which returns an empty string specifically for the English language instead of a locale code like en-EN
. This empty string makes its way back to GetRelevantLocales where the while loop sees an empty string and so skips to just adding default
as the only relevant locale, which then means the eventual code that loads the actual .json files only knows to load default.json
.
In my testing, making BaseContentManager.GetLocale(LanguageCode language)
return en-EN
if it receives an empty string from the game was enough to make SMAPI correctly load my en.json
i18n file, though I can't say I'm fully aware of any consequences of doing so elsewhere in SMAPI (i.e. I don't know if anywhere else strictly relies on an empty string for the English locale, such as maybe locale-specific asset loading). Adjusting GetRelevantLocales
is probably better.
To Reproduce:
- Create an i18n folder in your mod and populate a
default.json
- Create an
en.json
with values that differ fromdefault.json
- Use the i18n system for some text in-game
- Launch the game and see that the game uses your
default.json
values instead of youren.json
values, even when your game is set to the English locale.