Localize the homepage selector too
This commit is contained in:
parent
76493d48ee
commit
79978f026f
1 changed files with 8 additions and 6 deletions
|
@ -1,8 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
// $FlowFixMe
|
import { getLanguageName } from 'constants/languages';
|
||||||
import homepages from 'homepages';
|
|
||||||
import { getLanguageEngName } from 'constants/languages';
|
|
||||||
import { FormField } from 'component/common/form';
|
import { FormField } from 'component/common/form';
|
||||||
import { getDefaultHomepageKey } from 'util/default-languages';
|
import { getDefaultHomepageKey } from 'util/default-languages';
|
||||||
|
|
||||||
|
@ -13,14 +11,18 @@ type Props = {
|
||||||
|
|
||||||
function SelectHomepage(props: Props) {
|
function SelectHomepage(props: Props) {
|
||||||
const { homepage, setHomepage } = props;
|
const { homepage, setHomepage } = props;
|
||||||
|
const homepages = window.homepages || {};
|
||||||
|
const homepageKeys = Object.keys(homepages);
|
||||||
|
|
||||||
function handleSetHomepage(e) {
|
function handleSetHomepage(e) {
|
||||||
const { value } = e.target;
|
const { value } = e.target;
|
||||||
setHomepage(value);
|
setHomepage(value);
|
||||||
}
|
}
|
||||||
if (Object.keys(homepages).length <= 1) {
|
|
||||||
|
if (homepageKeys.length <= 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<FormField
|
<FormField
|
||||||
|
@ -29,9 +31,9 @@ function SelectHomepage(props: Props) {
|
||||||
onChange={handleSetHomepage}
|
onChange={handleSetHomepage}
|
||||||
value={homepage || getDefaultHomepageKey()}
|
value={homepage || getDefaultHomepageKey()}
|
||||||
>
|
>
|
||||||
{Object.keys(homepages).map((hp) => (
|
{homepageKeys.map((hp) => (
|
||||||
<option key={'hp' + hp} value={hp}>
|
<option key={'hp' + hp} value={hp}>
|
||||||
{`${getLanguageEngName(hp)}`}
|
{getLanguageName(hp)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
Loading…
Reference in a new issue