Verified Commit 7769193f authored by Rejo Zenger's avatar Rejo Zenger

Merge branch 'master' into feature/duplicate-identifiers-v2

parents 19c2df45 308d8943
......@@ -6,7 +6,7 @@ import Help from 'components/Help';
import withRequest, { IWithRequestProps } from 'components/Request/withRequest';
import { Question } from 'components/Text';
import { Request } from 'lib/constants';
import { AVAILABLE_LOCALES } from 'lib/createI18N';
import { letters } from 'lib/generateLetter';
import { ITranslatedProps } from 'lib/prop-types';
interface ILanguageProps extends IWithRequestProps, ITranslatedProps {}
......@@ -23,15 +23,17 @@ class Language extends React.PureComponent<ILanguageProps, never> {
render() {
const { t, request } = this.props;
const { language } = request;
const locales = Object.keys(AVAILABLE_LOCALES);
const { language, type } = request;
const availableLocaleCodes = Object.keys(letters).filter(
key => !!letters[key][type]
);
return (
<React.Fragment>
<Question>{t('request.step.language.title')}</Question>
<Help title=" " />
{locales.map(locale => (
{availableLocaleCodes.map(locale => (
<Group key={locale}>
<Radio
packed
......
......@@ -5,10 +5,12 @@ import { reactI18nextModule } from 'react-i18next';
const AVAILABLE_LOCALES = {};
const localeFiles = require.context('locales/', true, /\.json$/);
localeFiles.keys().forEach(filename => {
const codeMatch = filename.match(/\.\/([^\.]+)/);
if (codeMatch) {
AVAILABLE_LOCALES[codeMatch[1]] = { translations: localeFiles(filename) };
if (codeMatch[1] !== 'en') {
require(`moment/locale/${codeMatch[1]}.js`);
}
......
......@@ -9,7 +9,7 @@ interface IHandlebarsMap {
[type: string]: (attributes: IHandlebarsAttributes) => string;
}
const letters: { [locale: string]: IHandlebarsMap } = {};
export const letters: { [locale: string]: IHandlebarsMap } = {};
const fallbackLocale = 'en';
const fallbackAttributes: Partial<Request.Attributes> = {
organization: { address: {} },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment