See https://github.com/edx/edx-platform/blob/master/docs/en_us/developers/source/i18n.rst#editing-source-files

this one is pretty tricky, I think your suggestion would work - it would be better to have the text live in the template file and not be injected via javascript though.