Skip to content

Conversation

@dbkr
Copy link
Member

@dbkr dbkr commented Nov 26, 2025

  • Adds a context that holds the module i1n API
  • Switches shared components to use that instead of importing it directly
  • Adds the context to MatrixChat and BaseDalog so it should be available most places in EW

This is a relatively small PR (or started as one) but does change the way the shared components do i18n so just doing this one by itself (it stands by itself anyway).

This will allow shared components to use i18n when used in modules.

Needs element-hq/element-modules#137 and a release of the module API for type check to pass.

Checklist

 * Adds a context that holds the module i1n API
 * Switches shared components to use that instead of importing it directly
 * Adds the context to MatrixChat and BaseDalog so it should be available most places in EW

This is a relatively small PR but does change the way the shared components do i18n so
just doing this one by itself (it stands by itself anyway).

This will allow shared components to use i18n when used in modules.
@dbkr dbkr added the T-Task Tasks for the team like planning label Nov 26, 2025
Then it should continue to get picked up by the script

This seems a bit flaky and ew but I'm not sure I want to get into
changing this in this PR.
Copy link
Member

@florianduros florianduros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can avoid to declare in each stories the i18n provider. Also should we this new i18n api instead of using:

async function languageLoader(context: StoryContext<ReactRenderer, StrictArgs>): Promise<void> {
await setLanguage(context.globals.language);
}

});
return <AudioPlayerView vm={vm} />;
return (
<I18nContext.Provider value={new I18nApi()}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a decorator in .storybook/preview.ts like for the TooltipProvider. so every stories will be wrapped inside this provider.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, I thought there ought to be a better way of doing that - should have just asked. Thanks.

@dbkr
Copy link
Member Author

dbkr commented Nov 28, 2025

We can avoid to declare in each stories the i18n provider

Not sure what you meant by this?

Also yeah, we could certainly add more stuff like setLanguage (and probably should): I can add it it to this PR but thought it might be better to keep it minimal to what we need right now.

Comment on lines 68 to 72
<I18nContext.Provider value={new I18nApi()}>
<TooltipProvider>
<Story />
</TooltipProvider>
</I18nContext.Provider>
Copy link
Member

@florianduros florianduros Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move it to its own storybook decorator? So we each context has its own decorator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Task Tasks for the team like planning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants