Internationalization of input elements added by Javascipt

I’m new to Keycloak and I’m trying to create a custom registration page. For this I have to create two dropdown fields that are dependent on each other. I would like to generate this using Javascript. So far everything works. However, the text fields should be internationalized.
If I add “$ {msg (” text “)}” as a text element with JS, no translation takes place. I think the translation takes place in a controller before the page is output?!
Is there a possibility to use the with dynamically created elements?