Skip to content

Add Transloco to external component library. #514

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

Open
1 task done
TomRaaff opened this issue Oct 7, 2021 · 1 comment
Open
1 task done

Add Transloco to external component library. #514

TomRaaff opened this issue Oct 7, 2021 · 1 comment

Comments

@TomRaaff
Copy link

TomRaaff commented Oct 7, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Which Transloco package(s) will this feature affect?

Transloco

Is your feature request related to a problem? Please describe

So far I've seen implementations for Transloco and shared translations in libs within a mono-repo. However, we don't have a mono-repo, but a MainProject that depends on a ComponentLibrary. I want to use Transloco in both. I've added Transloco to the MainProject without issue. However, when I add it to the ComponentLibrary, I get problems due to having two HttpClient instances. (The ComponentLib needed an HttpClient so it could fetch the translationsfile).

Besides that, I forsee some other problems:

  • If I have two HttpClients, I'll have two TranslocoServices as well
  • with two TranslocoServices, the changing of language will be executed by only 1 of them.
  • How do I manage my translations? Can I add translationfiles to the library or does the MainProject need to contain the translations for the library as well?

Describe the solution you'd like

Documentation on how to add Transloco to an external library

Describe alternatives you've considered

No response

Describe alternatives you've considered

Implementing our project as a mono-repo, but that is not an option.

Describe alternatives you've considered

Expected behaviour: I expect transloco to be usable among multiple projects/libraries and for there to be a way to easily maintain the translations

Additional context

No response

I would like to make a pull request for this feature

No

@Serrulien
Copy link
Contributor

Serrulien commented Oct 27, 2021

Hello,

I'm maintaining a project similar to yours. However the library doesn't fetch its translation files by itself, the consumer of the library must do it.

The translation files of the library are bundled into its dist folder then transloco-scoped-libs will help you to extract them on the consumer side.

Read https://ngneat.github.io/transloco/docs/tools/scope-lib-extractor/ to know how to do it.

This strategy is useful when both consumer and libraries use transloco.

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

2 participants