Hello! I want to get a translated string with a key but it errors: key "build.hidden" for locale "fr-fr" not found in any active LocalizationTable
However, it is present:
local PlayersService = game:GetService("Players")
local LocalizationService = game:GetService("LocalizationService")
local success, translator = pcall(function()
local success, translator = pcall(LocalizationService:GetTranslatorForPlayerAsync(PlayersService.LocalPlayer))
if not success then
translator = LocalizationService:GetTranslatorForLocaleAsync(LocalizationService.RobloxLocaleId)
end
return translator
end)
if success then
print(translator:FormatByKey("build.hidden"))
else
warn("Failed to load translator for player with error: "..translator)
end
local LocalizationService = game:GetService("LocalizationService")
local HttpService = game:GetService("HttpService")
local function createLocalizationTable(contents)
local localTable = Instance.new("LocalizationTable")
localTable.DevelopmentLanguage = LocalizationService.SystemLocaleId
localTable.Contents = HttpService:JSONEncode(contents)
return localTable
end
local helloWorldTable = createLocalizationTable({
[1] = {
key = "build_hidden", -- The 'expressionKey' to be used with GetString
values = { -- A dictionary of keys corresponding to IETF language tags, and their translations.
["fr"] = "Build caché!", -- French
},
},
})
print(helloWorldTable:GetString("fr", "build_hidden"))