Using custom email provider action for localisation

Common approach for email template localisations seems to be quite akward if else liquid syntax in the templates:

Is there some reason the custom email provider could not be used for localisations?’

You could have for example a passwordless otp template in Auth0 email connection:

{% raw %}
{{ otpHeader }}
{% endraw %}
{{ code }}

Then in the custom provider action you would render the event.html content again with the dictionary and using the event.locale for deducting the selected language.

Action pseudo code:

exports.onExecuteCustomEmailProvider = async (event, api) => {
   const selectedLocale = deductLanguage(event.locale)
   const templateParams = { otpHeader: dictionary[selectedLocale].otpHeader }
   const emailContent = renderLiquid(event.html, templateParams)
   // send the email with e.g. sendgrid api
}