Internationalization of input elements added by Javascipt

Hi,
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 messages_xx.properties with dynamically created elements?