mirror of
https://github.com/shoelace-style/shoelace.git
synced 2026-01-12 02:59:13 +00:00
fix issues with no translation errors for bundled components (#1696)
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
import '../translations/en.js';
|
||||
import { LocalizeController as DefaultLocalizationController } from '@shoelace-style/localize'; // Register English as the default/fallback language
|
||||
import { LocalizeController as DefaultLocalizationController, registerTranslation } from '@shoelace-style/localize';
|
||||
import en from '../translations/en.js'; // Register English as the default/fallback language
|
||||
import type { Translation as DefaultTranslation } from '@shoelace-style/localize';
|
||||
|
||||
// Extend the controller and apply our own translation interface for better typings
|
||||
export class LocalizeController extends DefaultLocalizationController<Translation> {}
|
||||
export class LocalizeController extends DefaultLocalizationController<Translation> {
|
||||
// Technicallly '../translations/en.js' is supposed to work via side-effects. However, by some mystery sometimes the
|
||||
// translations don't get bundled as expected resulting in `no translation found` errors.
|
||||
// This is basically some extra assurance that our translations get registered prior to our localizer connecting in a component
|
||||
// and we don't rely on implicit import ordering.
|
||||
static {
|
||||
registerTranslation(en);
|
||||
}
|
||||
}
|
||||
|
||||
// Export functions from the localize lib so we have one central place to import them from
|
||||
export { registerTranslation } from '@shoelace-style/localize';
|
||||
|
||||
Reference in New Issue
Block a user