我使用react-intl,我想使用以下代码区域:en-US,en-GB ...
import { IntlProvider, addLocaleData } from "react-intl";
import messages_en from "locales/en_GB.json";
import messages_fr from "locales/fr_FR.json";
const localeData = {
"fr_FR": messages_fr,
"en_GB": messages_en
};
const language = (navigator.languages && navigator.languages[0]) ||
navigator.language || navigator.userLanguage;
const languageWithoutRegionCode = language.replace("-", "_");
const messages = localeData[languageWithoutRegionCode] ||
localeData[language] || localeData.fr;
ReactDOM.render(
<IntlProvider locale={language} messages={messages}>
.......
</IntlProvider>
但是,我有一个错误:[React Intl]缺少语言环境“ fr-FR”的语言环境数据。使用默认语言环境:“ en”作为后备。