|
|
@@ -24,7 +24,7 @@ class NCoreUIKitLocalize<T extends LocalizeType> extends NCoreContext<LocalizeCo
|
|
|
useContext = ({
|
|
|
activeLocale
|
|
|
}: {
|
|
|
- activeLocale?: NCoreUIKit.LocaleKey
|
|
|
+ activeLocale?: keyof NCoreUIKit.LocaleKey
|
|
|
} = {}): LocalizeContextType => {
|
|
|
const currentState = useContext(this.stateContext);
|
|
|
|
|
|
@@ -80,14 +80,14 @@ class NCoreUIKitLocalize<T extends LocalizeType> extends NCoreContext<LocalizeCo
|
|
|
}
|
|
|
|
|
|
prepare = (props?: {
|
|
|
- activeLocale?: NCoreUIKit.LocaleKey
|
|
|
+ activeLocale?: keyof NCoreUIKit.LocaleKey
|
|
|
}): LocalizeContextStateType => {
|
|
|
const locale = props && props.activeLocale ? props.activeLocale : this.state.activeLocale;
|
|
|
|
|
|
const defaultLocale = defaultLocalesData.find(l => l.locale === locale) ?? defaultLocalesData[0]!;
|
|
|
|
|
|
const defaultState: LocalizeContextStateType = {
|
|
|
- activeLocale: defaultLocale.locale as NCoreUIKit.LocaleKey,
|
|
|
+ activeLocale: defaultLocale.locale as keyof NCoreUIKit.LocaleKey,
|
|
|
// localizeWithObject: this.localizeWithObject,
|
|
|
translations: defaultLocale.translations,
|
|
|
isRTL: defaultLocale.isRTL
|
|
|
@@ -105,7 +105,7 @@ class NCoreUIKitLocalize<T extends LocalizeType> extends NCoreContext<LocalizeCo
|
|
|
}
|
|
|
|
|
|
const newState: LocalizeContextStateType = {
|
|
|
- activeLocale: currentProjectLocale.locale as NCoreUIKit.LocaleKey,
|
|
|
+ activeLocale: currentProjectLocale.locale as keyof NCoreUIKit.LocaleKey,
|
|
|
// localizeWithObject: this.localizeWithObject,
|
|
|
isRTL: currentProjectLocale.isRTL,
|
|
|
// localize: this.localize,
|
|
|
@@ -178,7 +178,7 @@ class NCoreUIKitLocalize<T extends LocalizeType> extends NCoreContext<LocalizeCo
|
|
|
switch = ({
|
|
|
localeKey
|
|
|
}: {
|
|
|
- localeKey: NCoreUIKit.LocaleKey
|
|
|
+ localeKey: keyof NCoreUIKit.LocaleKey
|
|
|
}) => {
|
|
|
const activeState = this.prepare({
|
|
|
activeLocale: localeKey
|
|
|
@@ -188,7 +188,7 @@ class NCoreUIKitLocalize<T extends LocalizeType> extends NCoreContext<LocalizeCo
|
|
|
};
|
|
|
|
|
|
updateProjectLocales = (newProjectLocales: NCoreUIKit.Locales, newState?: {
|
|
|
- activeLocale?: NCoreUIKit.LocaleKey
|
|
|
+ activeLocale?: keyof NCoreUIKit.LocaleKey
|
|
|
}) => {
|
|
|
this.projectLocales = newProjectLocales;
|
|
|
const activeState = this.prepare(newState);
|