Im making a game and I want to add 2 languages to it. Where the player can change via in-game settings.
I wanted to know how language settings work. If I should use module scripts, arrays or something like that.
Im making a game and I want to add 2 languages to it. Where the player can change via in-game settings.
I wanted to know how language settings work. If I should use module scripts, arrays or something like that.
Maybe this can help you Localization | Documentation - Roblox Creator Hub
You donβt need to write another module for multiple languages. There is a Built-in Multi-Language System that Roblox will automatically detect.
You can manage the translation in the Translation Portal
If you want to use your module, hereβs an example of how it works.
Here an example of i18n Modules that I wrote, which are very simple, and very useless:
Structure:
i18n (ModuleScript)
- Languages (Folder)
- en_US
- en_UK
i18n
local i18n_module= {}
function i18n:New(language: string)
local LocaleModule = script.Languages:FindFirstChild(language)
if not LocaleModule then error("Language Not Found") end
local Locale = require(LocaleModule)
local i18n = {}
function i18n:get(locale_string: string)
return Locale[locale_string] or locale_string
end
return i18n
end
return i18n_module
en_US, en_UK
return {
["Example Text"] = "Example Text"
}