Internationalization and localization
Internationalization, often abbreviated as i18n, implies a particular software design capable of adapting to the requirements of target local markets. In other words, if we want to distribute our application to markets other than the USA, we need to take care of translations, formatting of datetime, numbers, addresses, and such.
Date format by country
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...