How to I18n content which is dynamically loaded via javascript (assets)?

Suppose there is some content which is added dynamically by javascript because it provides javascript functionality only. As an example, I could imagine some buttons to sort a table with the help of js like in https://github.com/foodcoop-rostock/foodsoft/blob/improve-delivery-workflow-further/app/assets/javascripts/application.js#L135 .

How to handle these expressions correctly? I guess the code should be moved to a place where embedded ruby is allowed, but I could not find an example.

we can use:
https://github.com/fnando/i18n-js

it converts the locale files to js. In JS you can do I18n.t(‘key’)…