dojo / i18n

:rocket: Dojo 2 - internationalization library.
http://dojo.io
Other
6 stars 19 forks source link

Creating and Loading Language Resources #15

Closed kitsonk closed 7 years ago

kitsonk commented 8 years ago

@kitsonk commented on Wed Jul 06 2016

The most basic use case that falls under i18n is the ability to specify a language/region code and an identifier which represents a resource (text or some other structure) which is suitable for the language code. The system needs to resolve the best match of language/region code.

@bryanforbes has worked on a concept of using ES Observables which provide subscribers with the current language codes resources. If the language code is changed, the observables will publish the changed resources and the consumer reacts to that change. While this is an elegant solution, I wonder how this scales when you have a significant amount of subscriptions and does the frequency of changes during a lifecycle of a loaded page. For example, would if a region change that required a page reload be too limiting of a use case in order to simplify how the mechanism would work.

In Dojo 1, the resources are loaded using the AMD plugin mechanism. The long term disadvantage to requiring that for Dojo 2 means that the only way to get that functionality would be to use an AMD loader. The plugin architecture also looks like it might run into issues when the ES Module Loaders finally arrive natively, as they are unlikely to provide a "plugin" type interface, though the debate is currently ongoing.

So given all these considerations, this issue it to lay out a proposal of creating resource bundles, loading them and offering them up to a consumer.


@kitsonk commented on Wed Jul 06 2016

Summary of a discussion between @matt-gadd and myself...

Since the larger Dojo 2 Widget system is generally a pull system, it is logical that the i18n system be a lazy loaded pull system. The flow would be something like this:


@kitsonk commented on Thu Jul 07 2016

Actually further discussion with @matt-gadd and @agubler clarified something that would be a better pattern that fits into the Dojo 2 Widget system:

mwistrand commented 7 years ago

Resolved by #11 and #26.