Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/add flags to general settings language dropdown #378

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/images/flags/chinese.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/flags/english.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/flags/french.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/flags/german.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/flags/japanese.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/flags/korean.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/flags/russian.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions app/components/settings/categories/GeneralSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ReactToolboxMobxForm from '../../../utils/ReactToolboxMobxForm';
import LocalizableError from '../../../i18n/LocalizableError';
import styles from './GeneralSettings.scss';
import type { ReactIntlMessage } from '../../../types/i18nTypes';
import SvgInline from 'react-svg-inline';

const messages = defineMessages({
languageSelectLabel: {
Expand All @@ -19,7 +20,7 @@ const messages = defineMessages({
});

type Props = {
languages: Array<{ value: string, label: ReactIntlMessage }>,
languages: Array<{ value: string, label: ReactIntlMessage, svg: string }>,
currentLocale: string,
onSelectLanguage: Function,
isSubmitting: boolean,
Expand Down Expand Up @@ -60,7 +61,8 @@ export default class GeneralSettings extends Component<Props> {
const languageId = form.$('languageId');
const languageOptions = languages.map(language => ({
value: language.value,
label: intl.formatMessage(language.label)
label: intl.formatMessage(language.label),
svg: language.svg
}));
const componentClassNames = classNames([styles.component, 'general']);
const languageSelectClassNames = classNames([
Expand All @@ -76,6 +78,12 @@ export default class GeneralSettings extends Component<Props> {
{...languageId.bind()}
onChange={this.selectLanguage}
skin={SelectSkin}
optionRenderer={option => (
<div>
<SvgInline svg={option.svg} className={styles.flag} width="30" height="27" />
<span className={styles.language}>{option.label}</span>
</div>
)}
/>
{error && <p className={styles.error}>{error}</p>}

Expand Down
10 changes: 10 additions & 0 deletions app/components/settings/categories/GeneralSettings.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import '../../../themes/mixins/error-message';

$flagSize: 30px;

.component {
margin-bottom: 20px;

Expand All @@ -18,4 +20,12 @@
text-align: center;
}

.flag {
margin-right: $flagSize / 4;
}

.language {
line-height: $flagSize;
vertical-align: top;
}

16 changes: 8 additions & 8 deletions app/stores/toplevel/ProfileStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import globalMessages from '../../i18n/global-messages';
export default class SettingsStore extends Store {

LANGUAGE_OPTIONS = [
{ value: 'en-US', label: globalMessages.languageEnglish },
{ value: 'ja-JP', label: globalMessages.languageJapanese },
{ value: 'ko-KR', label: globalMessages.languageKorean },
{ value: 'zh-Hans', label: globalMessages.languageChineseSimplified },
{ value: 'zh-Hant', label: globalMessages.languageChineseTraditional },
{ value: 'ru-RU', label: globalMessages.languageRussian },
{ value: 'de-DE', label: globalMessages.languageGerman },
{ value: 'fr-FR', label: globalMessages.languageFrench },
{ value: 'en-US', label: globalMessages.languageEnglish, svg: require('../../assets/images/flags/english.inline.svg') },
{ value: 'ja-JP', label: globalMessages.languageJapanese, svg: require('../../assets/images/flags/japanese.inline.svg') },
{ value: 'ko-KR', label: globalMessages.languageKorean, svg: require('../../assets/images/flags/korean.inline.svg') },
{ value: 'zh-Hans', label: globalMessages.languageChineseSimplified, svg: require('../../assets/images/flags/chinese.inline.svg') },
{ value: 'zh-Hant', label: globalMessages.languageChineseTraditional, svg: require('../../assets/images/flags/chinese.inline.svg') },
{ value: 'ru-RU', label: globalMessages.languageRussian, svg: require('../../assets/images/flags/russian.inline.svg') },
{ value: 'de-DE', label: globalMessages.languageGerman, svg: require('../../assets/images/flags/german.inline.svg') },
{ value: 'fr-FR', label: globalMessages.languageFrench, svg: require('../../assets/images/flags/french.inline.svg') }
];

@observable bigNumberDecimalFormat = {
Expand Down