Skip to content

Commit 4ac6cb9

Browse files
Merge branch 'master' into rivanova/tooltip-click
2 parents 84d87f4 + a676033 commit 4ac6cb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1250
-289
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ i18nRepo
3535
.env
3636
.envrc
3737
.direnv
38+
39+
.vs

.storybook/preview.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ import { type CSSResult, html } from 'lit';
44
import { configureTheme } from '../src/theming/config';
55
import type { Decorator, Preview } from '@storybook/web-components-vite';
66
import { withActions } from 'storybook/actions/decorator';
7+
import { registerI18n } from 'igniteui-i18n-core';
8+
import {
9+
ResourceStringsBG,
10+
ResourceStringsDE,
11+
ResourceStringsES,
12+
ResourceStringsFR,
13+
ResourceStringsJA,
14+
} from 'igniteui-i18n-resources';
15+
16+
const LocalizationResources = new Map(
17+
Object.entries({
18+
de: ResourceStringsDE,
19+
fr: ResourceStringsFR,
20+
es: ResourceStringsES,
21+
ja: ResourceStringsJA,
22+
bg: ResourceStringsBG,
23+
})
24+
);
725

826
type ThemeImport = { styles: CSSResult };
927

@@ -62,6 +80,12 @@ const themeProvider: Decorator = (story, context) => {
6280
`;
6381
};
6482

83+
const localeProvider: Decorator = (story, context) => {
84+
const { localization } = context.globals;
85+
document.documentElement.lang = localization ?? 'en';
86+
return story();
87+
};
88+
6589
export default {
6690
globalTypes: {
6791
theme: {
@@ -102,6 +126,21 @@ export default {
102126
],
103127
},
104128
},
129+
localization: {
130+
name: 'Localization',
131+
description: 'Component localization',
132+
toolbar: {
133+
icon: 'globe',
134+
items: [
135+
{ value: 'en', title: 'English' },
136+
{ value: 'de', title: 'German' },
137+
{ value: 'fr', title: 'French' },
138+
{ value: 'es', title: 'Spanish' },
139+
{ value: 'ja', title: 'Japanese' },
140+
{ value: 'bg', title: 'Bulgarian' },
141+
],
142+
},
143+
},
105144
size: {
106145
name: 'Size',
107146
description: 'Component size',
@@ -120,16 +159,21 @@ export default {
120159
theme: 'bootstrap',
121160
variant: 'light',
122161
direction: 'ltr',
162+
localization: 'en',
123163
size: 'default',
124164
},
125165
parameters: {
126166
backgrounds: {
127167
disable: true,
128168
},
129169
},
130-
decorators: [themeProvider, withActions],
170+
decorators: [themeProvider, withActions, localeProvider],
131171
loaders: [
132172
async (context) => {
173+
for (const [locale, resources] of LocalizationResources.entries()) {
174+
registerI18n(resources, locale);
175+
}
176+
133177
const { theme, variant } = context.globals;
134178
return { theme: getTheme({ theme, variant }) };
135179
},

0 commit comments

Comments
 (0)