shopify functions translation

I found a way, don’t know if it is THE way.
So first I found there was a localization field in RunInput:
in run.graphql:
localization{
language{
isoCode
}
}

then I used this to select a json file in my locales folder:

function chooseTranslationByLanguage(isoCode) {
switch (isoCode) {
case ‘FR’:
return require(‘../locales/fr.json’);
case ‘NL’:
return require(‘../locales/nl.json’);
case ‘DE’:
return require(‘../locales/de.json’);
case ‘EN’:
default:
return require(‘../locales/en.default.json’);
}
}

And I use it like this:

message: chooseTranslationByLanguage(input.localization.language.isoCode).discount.replace(‘{percent}’, disc).replace(‘{qty}’, qty)

I will mark this as the solution, but if there is a better method pls let me know.