There is an OOTB function CQ.I18n.getDictionary() to get translations, but it always gets the whole dictionary to the UI, which puts much load on the visitor's browser. This reuest is to provide a function that retrieves only the requested translations. E.g. it could accept key name(s) and language name as parameters.
Use localized strings in custom JS code on user-facing pages.
Environment Details (AEM version/service pack, any other specifics if applicable):