How can I use two translators first for JSON file and second for firestore?

扶醉桌前 提交于 2019-12-22 01:32:02

问题


JSON File Method

export function createTranslateLoader(http: HttpClient) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

JSON File Loader

 TranslateModule.forRoot({
          loader: {
              provide: TranslateLoader,
              useFactory: (createTranslateLoader),
              deps: [HttpClient]
          }
      }),

AngularFirestore Method

export function FirestoreTranslationsLoaderFactory(db: AngularFirestore) {
  return new FirestoreTransLoader(db);
}

AngularFirestore File Loader

TranslateModule.forRoot({
      loader: {
           provide: TranslateLoader,
           useFactory: FirestoreTranslationsLoaderFactory, 
           deps: [AngularFirestore]
        }
    }),

Note: I can't use two same time I try to merge in one method and Loader.


回答1:


Like I have already answered you in the comments section:

I think that storing theoretically one piece of data separately in two places is not the best idea.

But if you need something like that you can use MissingTranslationHandler like I have done here:
https://github.com/Mr-Eluzive/angularfire-ngx-translate-example/tree/missing-translation-handler
You can check out diffs between this branch and master to get familiar with what has to bo done to make it works.



来源:https://stackoverflow.com/questions/52621942/how-can-i-use-two-translators-first-for-json-file-and-second-for-firestore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!