Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// append timeout option
newOptions = {
timeout: pconf.request.timeout,
...newOptions,
};
// append no cache headers
newOptions.headers = {
...NOCACHE_HEADERS,
...newOptions.headers,
};
// append accept-language header
newOptions.headers = {
'Accept-Language': getLocale(),
...newOptions.headers,
};
return newOptions;
}
export default () => {
console.log(getLocale(), formatMessage({
id: 'test'
}, {
name: 'antd'
}));
return (
<div>
hello world.
<button> {
setLocale('en-US');
}}>en-US</button>
<button> {
setLocale('zh-CN');
}}>zh-CN</button>
</div>
)
};
changLang = () => {
const locale = getLocale();
if (!locale || locale === 'zh-CN') {
setLocale('en-US');
} else {
setLocale('zh-CN');
}
};
const temp = () => {
const locale = getLocale();
const style = {
backgroundColor: 'red',
}
return (
<div>
<br><br>
<button style="{locale"> {
setLocale('zh-CN');
}}
>
zh-CN
</button>
</div>
render() {
const { className } = this.props;
const selectedLang = getLocale();
const locales = ['zh-CN', 'en-US'];
const languageLabels = {
'zh-CN': '简体中文',
'zh-TW': '繁体中文',
'en-US': 'English',
'pt-BR': 'Português',
};
const languageIcons = {
'zh-CN': '🇨🇳',
'zh-TW': '🇭🇰',
'en-US': '🇬🇧',
'pt-BR': '🇧🇷',
};
const langMenu = (
<menu>
{locales.map(locale => (</menu>
export default page => withIntl(getFloder(getLocale()), page);
render() {
const { className } = this.props;
const selectedLang = getLocale();
const langMenu = (
<menu>
<span aria-label="简体中文" role="img">
🇨🇳
</span>{' '}
简体中文
<span aria-label="繁体中文" role="img">
🇭🇰
</span>{' '}
繁体中文
<span aria-label="English" role="img"></span></menu>
render() {
const { className } = this.props;
const selectedLang = getLocale();
const locales = ['zh-CN', 'en-US'];
const languageLabels = {
'zh-CN': '简体中文',
'en-US': 'English',
};
const languageIcons = {
'zh-CN': '🇨🇳',
'en-US': '🇬🇧',
};
const langMenu = (
<menu>
{locales.map(locale => (
<span aria-label="{languageLabels[locale]}" role="img">
{languageIcons[locale]}
</span>{' '}</menu>