I do not understand how to get translation with key

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:

pls help thanks

EDIT: Here’s my code, i forgot

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
2 Likes

You need to create a LocalizationTable.


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"))
1 Like

Yeah but, I want it to use the cloud table.
How would I do that?

1 Like

Bumping this. Please help! This has been bugging me for 6 months!!

hi again citizens
help me pls.

oh hey it started working, guess it was a bug after all.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.