angular-localization
angular-localization copied to clipboard
Better behavior for getText when locale isn't loaded.
https://github.com/doshprompt/angular-localization/blob/master/src/localization.js#L248-L267
getLocalizedString may release Zalgo.
I've got a big mess of an app. You don't care about that. It uses the i18n filter, which calls locale.getString, which is getLocalizedString. This returns an empty string because the bundle is not loaded, and triggers the bundle load. My app then goes on to do the wrong thing, assuming the empty string is the correct translation.
I feel like maybe there should be a stronger indicator that the bundle isn't loaded yet. Maybe throw an exception, or, if that's too harsh, return '%%BUNDLE_NOT_LOADED%%', (with analogy to '%%KEY_NOT_FOUND%%') I guess you could make the i18n filer return a promise that will be fulfilled once the bundle is loaded, (I hear that's supposed to work.)
Also, I want a pony. Er, I mean, this is basically wishing, but it might help others too.