2020-01-18 02:07:52 +05:30
|
|
|
import React, { ComponentType, ReactNode } from 'react';
|
2019-12-08 00:32:00 +05:30
|
|
|
import { localeFlags } from 'app/components/i18n';
|
2017-12-31 03:08:54 +05:30
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
2019-12-07 16:58:52 +05:30
|
|
|
|
2017-12-31 03:08:54 +05:30
|
|
|
import messages from './languageSwitcher.intl.json';
|
|
|
|
import styles from './languageSwitcher.scss';
|
2019-12-07 16:58:52 +05:30
|
|
|
import { LocaleData } from './LanguageSwitcher';
|
2017-12-31 03:08:54 +05:30
|
|
|
|
2020-01-18 02:07:52 +05:30
|
|
|
interface Props {
|
|
|
|
locale: LocaleData;
|
|
|
|
}
|
2017-12-31 03:08:54 +05:30
|
|
|
|
2020-01-18 02:07:52 +05:30
|
|
|
const LocaleItem: ComponentType<Props> = ({
|
|
|
|
locale: { code, name, englishName, progress, isReleased },
|
|
|
|
}) => {
|
|
|
|
let progressLabel: ReactNode;
|
2017-12-31 03:08:54 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
if (progress !== 100) {
|
|
|
|
progressLabel = (
|
|
|
|
<Message
|
|
|
|
{...messages.translationProgress}
|
|
|
|
values={{
|
|
|
|
progress,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
} else if (!isReleased) {
|
|
|
|
progressLabel = <Message {...messages.mayBeInaccurate} />;
|
|
|
|
}
|
2017-12-31 03:08:54 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
return (
|
|
|
|
<div className={styles.languageFlex}>
|
|
|
|
<div
|
|
|
|
className={styles.languageIco}
|
|
|
|
style={{
|
|
|
|
backgroundImage: `url('${localeFlags.getIconUrl(code)}')`,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<div className={styles.languageCaptions}>
|
|
|
|
<div className={styles.languageName}>{name}</div>
|
|
|
|
<div className={styles.languageSubName}>
|
|
|
|
{englishName} {progressLabel ? '| ' : ''} {progressLabel}
|
2017-12-31 03:08:54 +05:30
|
|
|
</div>
|
2019-11-27 14:33:32 +05:30
|
|
|
</div>
|
|
|
|
<span className={styles.languageCircle} />
|
|
|
|
</div>
|
|
|
|
);
|
2020-01-18 02:07:52 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
export default LocaleItem;
|