Hello,
I am trying to localize my entire application but I cannot get this example working; https://www.telerik.com/kendo-react-ui/components/intl/l10n/reacting-to-language-changes/
My code is below.
import { Message } from '../../common/Message';
loadMessages(messages["es"], "es");
const DetailComponent = (props: any) => {
const locales: LocaleInterface[] = [
{
language: "en-US",
locale: "en",
},
{
language: "es-ES",
locale: "es",
},
];
const [currentLocale, setCurrentLocale] = React.useState<LocaleInterface>(
locales[0]
);
const defaultMessages = {
[yesterdaysMessageKey]: "Yesterday was a good day!",
[todaysMessages]: "Today is a good day as well!",
[tomorrowsMessageKey]: "Tomorrow will be even better!",
};
return (
<LocalizationProvider language={currentLocale.language}>
<IntlProvider locale={currentLocale.locale}>
<p>
<strong> <Message messageKey={yesterdaysMessageKey} defaultMessage={defaultMessages[yesterdaysMessageKey]}/>:</strong> {dataItem.nickname}
</p>
</IntlProvider>
</LocalizationProvider>
);
};
import * as React from "react";
import { useLocalization } from "@progress/kendo-react-intl";
interface MessageProps {
messageKey: string;
defaultMessage: string;
}
export const Message = (props: MessageProps) => {
const localization = useLocalization();
return (
<span style={{ display: "block" }}>
{localization.toLanguageString(props.messageKey, props.defaultMessage)}
</span>
);
};
export interface LocaleInterface {
language: string;
locale: string;
}