#Translations issue with Helmod + Recipe Book
1 messages · Page 1 of 1 (latest)
When a game starts, Recipe Book requests a whole load of translations. Helmod won't request it's translations until later.
However Helmod does add a listener to the on_string_translated event
It pulls apart the localised_string event parameter to find a string to use as a key.
function User.addTranslate(request)
if request.translated == true then
local localised_string = request.localised_string
local string_translated = request.result
if type(localised_string) == "table" then
local localised_value = localised_string[1]
if localised_value ~= nil and localised_value ~= "" then
local _,key = string.match(localised_value,"([^.]*).([^.]*)")
if key ~= nil and key ~= "" then
local translated = User.get("translated")
translated[key] = string_translated
end
end
end
end
end
These days, the request translation function returns an ID that you can store in global, and match with the ID given in the response event. That will solve all of these potential problems.
Flib dictionary used to use a similar method of embedding the key in the string request, but now that's no longer necessary.
I should definitely add an option to flib to defer the translation requests until you explicitly request it though. They don't always need to be done on game start.