July 2017
Intermediate to advanced
300 pages
5h 43m
English
Internationalization is a cross-cutting concern. When you are changing the locale, it usually affects multiple modules. So, I suggest going with the observer pattern that we already examined while working on DirService: ./js/Service/I18n.js
const EventEmitter = require( "events" ); class I18nService extends EventEmitter { constructor(){
super(); this.locale = "en-US"; } notify(){ this.emit( "update" ); } } exports.I18nService = I18nService;
As you see, we can change the locale property by setting a new value to the locale property. As soon as we call the notify method, all the subscribed modules immediately respond.
However, locale is a public property and therefore we have no control over its access and ...
Read now
Unlock full access