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

Add i18next guard #105

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

kfrancois
Copy link

Summary

The experience of using

data: { i18nextNamespaces: ['...'] },
resolve: { i18next: I18NEXT_NAMESPACE_RESOLVER },

Is slightly brittle, as it's easy to forget I18NEXT_NAMESPACE_RESOLVER. Although easy to catch manually in development, it's hard to protect against regression during refactoring.

In our repo we added a helper to move this to a (functional) guard. This guard basically reimplements the i18nextNamespaceResolverFactory while adding the functionality of blocking navigation while namespaces are loading.

Example

Before

{
  path: 'rich_form',
  loadChildren: () => RichFormFeatureModule,
  data: { i18nextNamespaces: ['feature.rich_form'] },
  resolve: { i18next: I18NEXT_NAMESPACE_RESOLVER },
},

After

{
  path: 'rich_form',
  loadChildren: () => RichFormFeatureModule,
  canActivate: [i18NextNamespacesGuard('feature.rich_form')],
},

@Romanchuk
Copy link
Owner

@kfrancois Hi! Thank you for PR.
Interesting idea. I should deep dive to it. Could you update your fork from master?
I can't say right now... we might need both guard and resolver. But if we keep resolver - we need to make it also functional since Angular deprecated currently implemented resolver behavior

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

Successfully merging this pull request may close these issues.

2 participants