Empty
Empty
Empty
LocalizationService is a service that helps you manage multiple languages and localize your game for players around the world.
Empty
Empty
Empty
It allows you to translate and adapt your game’s text and other content to different languages and regions, making your game more accessible to a global audience.
Empty
Empty
Empty
local LocalizationService = game:GetService("LocalizationService")
local function createLocalizationTable(entries)
local localTable = Instance.new("LocalizationTable")
localTable.DevelopmentLanguage = LocalizationService.SystemLocaleId
localTable:SetEntries(entries)
localTable.Name = "GameLocalization"
localTable.Parent = LocalizationService
return localTable
end
local entries = {
{
Key = "Hello_World",
Values = {
["en"] = "Hello world!", -- English
["fr"] = "Bonjour le monde!", -- French
["de"] = "Hallo Welt!", -- German
}
}
}
createLocalizationTable(entries)
Empty
Empty
Empty
local LocalizationService = game:GetService("LocalizationService")
local Players = game:GetService("Players")
local helloWorldTable = LocalizationService:WaitForChild("GameLocalization")
local function getShortLocale(locale)
return string.sub(locale, 1, 2)
end
local function greetPlayer(player)
local locale = getShortLocale(player.LocaleId)
local message = helloWorldTable:GetString(locale, "Hello_World")
print(message)
end
Players.PlayerAdded:Connect(function(player)
greetPlayer(player)
end)
for _, player in pairs(Players:GetPlayers()) do
greetPlayer(player)
end
Empty
Empty
Empty
local LocalizationService = game:GetService("LocalizationService")
local Players = game:GetService("Players")
local helloWorldTable = LocalizationService:WaitForChild("GameLocalization")
local function getShortLocale(locale)
return string.sub(locale, 1, 2)
end
local function greetPlayer(player)
local locale = getShortLocale(player.LocaleId)
local message = helloWorldTable:GetString(locale, "Hello_World")
print(message)
end
local player = Players.LocalPlayer
greetPlayer(player)
If you found this tutorial helpful and would like to support my work, please consider buying me a coffee.
Thank you very much for your support!
Buy me a coffee