Cropster / ember-l10n

A GNU gettext based localization workflow for Ember
MIT License
15 stars 7 forks source link

Fingerprint locales #13

Closed mydea closed 7 years ago

mydea commented 7 years ago

This PR changes the default behavior of ember l10n:convert to create a fingerprinted locale file. The fingerprint is saved in the app/utils/l10n-fingerprint-map.js file, which is then retrieved from the l10n service.

Steps to upgrade to the new behavior:

1.) Upgrade ember-l10n 2.) Run ember g ember-l10n to generate the base l10n-fingerprint-map.js file, and make sure to also include the changes from the app/services/l10n.js file where the fingerprint map is loaded 3.) Re-run ember l10n:convert for all your locales to create the fingerprinted versions

LevelbossMike commented 7 years ago

Hi and thanks for this great addon! Is there any reason why the fingerprinting can't be done by using broccoli-asset-rev directly and adding .json-files to the extensions-fingerprint options?

mydea commented 7 years ago

The reason for this is that we load the locale files dynamically via ajax. So we'd need to know the fingerprint at runtime, which, as far as I researched, would only be possible by making ember-cli generate an fingerprint-asset-map.json file in the public folder, and then fetch that file via ajax, and get the correct path from there. This means that you need to delay loading of the app for after the asset-map file has been loaded, which adds one more request to your app, which feels really unnecessary. This approach here is slightly more complex, but ends up in a slimmer app. And since we provide our own "build process" with ember l10n:convert anyhow, that is basically hidden away from the developer anyhow - only migrating to this workflow doesn't happen automatically. Once you have done the (small) setup, everything should just work.

LevelbossMike commented 7 years ago

ah ok. makes sense. thx for clarifying and thanks again for this addon