Closed miiihi closed 8 years ago
Hello,
Thank you for your ideas. Loading namespaces individually is a good thing to add to this library, but I wouldn't implement this feature that way:
The main issue here is that if you desactivate the watcher, you'll stop watching all the other options (not only the namespaces).
The right thing to do for me would be:
options
loadNamespace(ns, [ns, …], callback)
function that adds them to options
and eventually registers the namespaces to load for the next steploadNamespace
with the right valuesIt is possible to add a promise return in addition to the callback capability if you wish on the exposed loadNamespace
function (I would like that myself).
Hi,
yes, there are several possible approaches... I just needed a quick fix. I was also thinking in direction of separating i18next options from ng-i18next options, that is calling init with a copy of options - window.i18next.init(angular.copy(ng-i18next-options)). That way, internal changes to i18next options wouldn't trigger the watcher and wouldn't reinitialize itself.
Promises are really nice feature, and they really nice part of ng - I use them a lot... So yes, let's add them
Regrads, Blaz
On Tue, Jul 22, 2014 at 2:46 PM, Etienne Folio notifications@github.com wrote:
Hello,
Thank you for your ideas. Loading namespaces individually is a good thing to add to this library, but I wouldn't implement this feature that way:
The main issue here is that if you desactivate the watcher, you'll stop watching all the other options (not only the namespaces).
The right thing to do for me would be:
- keep the watcher on options
- expose a loadNamespace(ns…) function that adds them to options and eventually registers the namespaces to load for the next step
- in the watcher, check the diff between the old and new options, and if only the namespaces have changed, trigger internally i18n's loadNamespace with the right values
- trigger an event when it's done
It is possible to add a promise return in addition to the callback capability if you wish on the exposed loadNamespace function (I would like that myself).
— Reply to this email directly or view it on GitHub https://github.com/archer96/ng-i18next/pull/52#issuecomment-49733642.
did this ever get implemented ? I am need of this functionality
Configuration and loading of the underlying i18next library now happens before Angular boots. This removed many timing issues with locales loading and filters getting digested prior to locales being loaded. I am closing this pull request.
I wanted to dynamically load additional namespaces. Current version doesn't support that - if I add a namespace to ng-i18next options, it reinitializes the i18n, which means, that it reloads all namespaces... If I use window.i18next.loadNamespace() function, we get the same result, as window.i18n.loadNamespace(), changes the i18next options, which are by ref the same as ng-i18next options, which then triggers the reinitialization again.
To add the feature:
My usage is now like this - set default options in any module config section:
In any controller or service...
On first loadNamespace() call i18next will be initialized, subsequent calls will just load additional namespaces... so every namespace is now loaded exactly once and, we get a promise of loading...