Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18n #64

Open
tomalaforge opened this issue Jun 13, 2021 · 5 comments
Open

I18n #64

tomalaforge opened this issue Jun 13, 2021 · 5 comments

Comments

@tomalaforge
Copy link

Hello,

Very nice project.
I have one question: how will you put i18n in that type of architecture ? Like transloco for instance ?
One json file per ui component or one global one ? But if you have multiple app sharing the same component, you'll have to duplicate keys.

Thanks

@trungvose
Copy link
Owner

@tomalaforge Great question, I don't really have experience with angular i18n so let me do some reading first before answering your question.
@nartc Do you have any input? 😎

@nartc
Copy link
Collaborator

nartc commented Jun 16, 2021

@tomalaforge Hi, for shared UI components (containing static texts that need to be translated), we can store the translations for these Shared components in a JSON file under scope common or shared.

We can initialize Transloco in a separate module with forRoot() for Multiple applications. In different apps, when calling this module, we can call forRoot() from the parent app and pass in different configuration to alter Transloco providers

@tomalaforge
Copy link
Author

@nartc I haven't thought of passing all config files thought forRoot(). I was looking on inline loader but that's not working for static UI components.

But do you have an example of your forRoot() app, you 're overwriting the TRANSLOCO_LOADER token?

@nartc
Copy link
Collaborator

nartc commented Jun 16, 2021

@tomalaforge I don't have an example but it should be just a ModuleWithProvider where we would provide a new value for TRANSLOCO_LOADER from each application.

Maybe some pseudo code

// TranslocoModule
export class TranslocoModule {
   static forRoot(config) {
      return {
         ngModule: TranslocoModule,
         providers: [
            { provide: TRANSLOCO_LOADER, useValue: config.loader }
         ]
      }
   }
}
// app1.module.ts
@NgModule({
   imports: [
      TranslocoModule.forRoot({ loader: something_for_app_1 })
   ]
})
export class App1Module {}
// app2.module.ts
@NgModule({
   imports: [
      TranslocoModule.forRoot({ loader: something_for_app_2 })
   ]
})
export class App2Module {}

@tomalaforge
Copy link
Author

Thanks very much. Sound promising. I'll try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants