What do you do in the case of localizationService:GetTranslatorForPlayerAsync failing?

Hi,

I’m just wondering what one would do in the case that localizationService:GetTranslatorForPlayerAsync fails (returns an error due to (likely) server issues)? The docs say that the method can fail, but not how one would go about handling the failure correctly.

Do I just use GetTranslatorForPlayer instead of the asynchronous version? I’m debating on whether or not this is the way to go because the docs say “This function is deprecated and should not be used in new work” underneath the related method section under GetTranslatorForPlayerAsync even though it doesn’t have the deprecated tag.

Any insight is appreciated, thanks.

3 Likes

I just put it in a pcall() like this

This is just an exestack snippet example I made (sorry for the bad formatting I wrote this here, this can be tested by anyone)

--@getTranslator/${player}/${doWhatever}

local success, translator = pcall(function()
   return localizationService:GetTranslatorForPlayerAsync(${player})
end)

if not success then
   warn("Failed to get the Player's Translator, Message:", translator)
else
   ${doWhatever}()
end

Yes I understand you’re supposed to wrap it in a pcall, but what do you do in the case of it failing? How are you supposed to obtain translated strings in that case?

Why didn’t you mention it in the post?

also I recommend doing some retries until it succeed or it reaches the max retries

I didn’t mention it because I guess I thought it was common sense to use a pcall when methods can error.

What should happen in the case of an outage and the max retry threshold is reached? That’s basically all I need to know, what do I use in case of the translator strictly not being available?