From 0698c337f82294e468de648ba21ff157e17a4071 Mon Sep 17 00:00:00 2001 From: Michael Schramm Date: Fri, 5 Jun 2020 12:54:01 +0200 Subject: [PATCH] add german ad english translations --- CHANGELOG.md | 1 + assets/global.scss | 13 +++ components/auth/footer.tsx | 22 ++++- components/form/admin/base.data.tab.tsx | 17 ++-- components/form/admin/design.tab.tsx | 21 ++-- components/form/admin/end.page.tab.tsx | 29 +++--- components/form/admin/field.card.tsx | 16 +-- components/form/admin/fields.tab.tsx | 4 +- .../admin/respondent.notifications.tab.tsx | 37 +++++-- .../form/admin/self.notifications.tab.tsx | 36 +++++-- components/form/admin/start.page.tab.tsx | 29 +++--- components/form/admin/types/radio.type.tsx | 14 +-- components/form/admin/types/rating.type.tsx | 2 +- components/form/admin/types/text.type.tsx | 2 +- components/structure.tsx | 27 ++++-- i18n.ts | 2 + locales/de/admin.ts | 8 ++ locales/de/common.ts | 7 ++ locales/de/form.ts | 97 +++++++++++++++++++ locales/de/index.ts | 28 +++++- locales/de/language.ts | 8 ++ locales/de/login.ts | 7 ++ locales/de/profile.ts | 10 ++ locales/de/register.ts | 6 ++ locales/de/statistic.ts | 5 + locales/de/submission.ts | 16 +++ locales/de/type.ts | 65 +++++++++++++ locales/de/user.ts | 18 ++++ locales/de/validation.ts | 15 +++ locales/en/form.ts | 75 +++++++++++++- locales/en/index.ts | 4 + locales/en/language.ts | 8 ++ locales/en/login.ts | 12 +-- locales/en/register.ts | 8 +- locales/en/type.ts | 25 ++++- locales/en/user.ts | 4 +- locales/en/validation.ts | 6 ++ pages/admin/forms/[id]/index.tsx | 14 +-- pages/admin/forms/create.tsx | 2 +- pages/admin/forms/index.tsx | 1 + pages/admin/profile.tsx | 2 +- pages/form/[id]/index.tsx | 15 ++- pages/login/index.tsx | 14 +-- pages/register.tsx | 18 ++-- 44 files changed, 633 insertions(+), 137 deletions(-) create mode 100644 locales/de/admin.ts create mode 100644 locales/de/common.ts create mode 100644 locales/de/form.ts create mode 100644 locales/de/language.ts create mode 100644 locales/de/login.ts create mode 100644 locales/de/profile.ts create mode 100644 locales/de/register.ts create mode 100644 locales/de/statistic.ts create mode 100644 locales/de/submission.ts create mode 100644 locales/de/type.ts create mode 100644 locales/de/user.ts create mode 100644 locales/de/validation.ts create mode 100644 locales/en/language.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 598e167..1a187f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - `SPA` env variable to have static page with loading spinner before redirect +- `de`, `fr`, `es`, `it`, `cn` base folders for translations ### Changed diff --git a/assets/global.scss b/assets/global.scss index b97f6d6..e54bd6f 100644 --- a/assets/global.scss +++ b/assets/global.scss @@ -35,3 +35,16 @@ position: fixed } } + +.admin { + .sidemenu { + .ant-layout-sider-children { + display: flex; + flex-direction: column; + + .language-selector { + padding-left: 12px !important; + } + } + } +} diff --git a/components/auth/footer.tsx b/components/auth/footer.tsx index 34c9405..61509c3 100644 --- a/components/auth/footer.tsx +++ b/components/auth/footer.tsx @@ -1,8 +1,10 @@ -import {Button} from 'antd' +import {UpOutlined} from '@ant-design/icons/lib' +import {Button, Menu, Select} from 'antd' import Link from 'next/link' import {useRouter} from 'next/router' import React from 'react' import {useTranslation} from 'react-i18next' +import {languages} from '../../i18n' import {clearAuth, withAuth} from '../with.auth' interface Props { @@ -13,7 +15,7 @@ interface Props { } const AuthFooterInner: React.FC = props => { - const { t } = useTranslation() + const { t, i18n } = useTranslation() const router = useRouter() const logout = () => { @@ -28,6 +30,8 @@ const AuthFooterInner: React.FC = props => { bottom: 0, left: 0, right: 0, + display: 'flex', + flexDirection: 'row', }} > @@ -72,14 +76,24 @@ const AuthFooterInner: React.FC = props => { ] )} - +
+
diff --git a/components/form/admin/field.card.tsx b/components/form/admin/field.card.tsx index 16ae054..b5c7b69 100644 --- a/components/form/admin/field.card.tsx +++ b/components/form/admin/field.card.tsx @@ -3,6 +3,7 @@ import {Button, Card, Checkbox, Form, Input, Popconfirm, Tag} from 'antd' import {FormInstance} from 'antd/lib/form' import {FieldData} from 'rc-field-form/lib/interface' import React, {useEffect, useState} from 'react' +import {useTranslation} from 'react-i18next' import {AdminFormFieldFragment} from '../../../graphql/fragment/admin.form.fragment' import {adminTypes} from './types' import {TextType} from './types/text.type' @@ -17,6 +18,7 @@ interface Props { } export const FieldCard: React.FC = props => { + const { t } = useTranslation() const { form, field, @@ -54,11 +56,11 @@ export const FieldCard: React.FC = props => { type={'inner'} extra={(
- {type} + {t(`type:${type}.name`)} { remove(index) @@ -75,7 +77,7 @@ export const FieldCard: React.FC = props => { > = props => { setNextTitle(e.target.value)}/> diff --git a/components/form/admin/fields.tab.tsx b/components/form/admin/fields.tab.tsx index 4c1e378..dcca2fc 100644 --- a/components/form/admin/fields.tab.tsx +++ b/components/form/admin/fields.tab.tsx @@ -3,6 +3,7 @@ import {Button, Form, Select, Space, Tabs} from 'antd' import {FormInstance} from 'antd/lib/form' import {TabPaneProps} from 'antd/lib/tabs' import React, {useCallback, useState} from 'react' +import {useTranslation} from 'react-i18next' import {AdminFormFieldFragment} from '../../../graphql/fragment/admin.form.fragment' import {FieldCard} from './field.card' import {adminTypes} from './types' @@ -14,6 +15,7 @@ interface Props extends TabPaneProps { } export const FieldsTab: React.FC = props => { + const { t } = useTranslation() const [nextType, setNextType] = useState('textfield') const renderType = useCallback((field, index, remove) => { @@ -41,7 +43,7 @@ export const FieldsTab: React.FC = props => { }} >
+ )} > @@ -96,9 +113,9 @@ export const RespondentNotificationsTab: React.FC = props => { diff --git a/components/form/admin/self.notifications.tab.tsx b/components/form/admin/self.notifications.tab.tsx index 8b6c8b9..1ce3aec 100644 --- a/components/form/admin/self.notifications.tab.tsx +++ b/components/form/admin/self.notifications.tab.tsx @@ -1,7 +1,9 @@ +import {InfoCircleOutlined} from '@ant-design/icons/lib' import {Form, Input, Select, Switch, Tabs} from 'antd' import {FormInstance} from 'antd/lib/form' import {TabPaneProps} from 'antd/lib/tabs' import React, {useEffect, useState} from 'react' +import {Trans, useTranslation} from 'react-i18next' import {AdminFormFieldFragment} from '../../../graphql/fragment/admin.form.fragment' interface Props extends TabPaneProps { @@ -10,6 +12,7 @@ interface Props extends TabPaneProps { } export const SelfNotificationsTab: React.FC = props => { + const { t } = useTranslation() const [enabled, setEnabled] = useState() useEffect(() => { @@ -38,7 +41,7 @@ export const SelfNotificationsTab: React.FC = props => { return ( @@ -46,12 +49,12 @@ export const SelfNotificationsTab: React.FC = props => { @@ -59,23 +62,36 @@ export const SelfNotificationsTab: React.FC = props => { MJML to create your email templates'} + extra={( +
+ form:selfNotifications.htmlTemplateInfo + + + +
+ )} >
diff --git a/components/form/admin/start.page.tab.tsx b/components/form/admin/start.page.tab.tsx index 5c283a2..9763654 100644 --- a/components/form/admin/start.page.tab.tsx +++ b/components/form/admin/start.page.tab.tsx @@ -2,13 +2,16 @@ import {DeleteOutlined, PlusOutlined} from '@ant-design/icons/lib' import {Button, Card, Form, Input, Switch, Tabs} from 'antd' import {TabPaneProps} from 'antd/lib/tabs' import React from 'react' +import {useTranslation} from 'react-i18next' import {InputColor} from '../../input/color' export const StartPageTab: React.FC = props => { + const { t } = useTranslation() + return ( @@ -16,21 +19,21 @@ export const StartPageTab: React.FC = props => { @@ -47,7 +50,7 @@ export const StartPageTab: React.FC = props => { wrapperCol={{ sm: { offset: index === 0 ? 0 : 6 }, }} - label={index === 0 ? 'Buttons' : ''} + label={index === 0 ? t('form:startPage.buttons') : ''} key={field.key} > = props => { ]} > - + - + - + - + - + @@ -96,7 +99,7 @@ export const StartPageTab: React.FC = props => { }} style={{ width: '60%' }} > - Add Button + {t('form:startPage.addButton')} diff --git a/components/form/admin/types/radio.type.tsx b/components/form/admin/types/radio.type.tsx index 6d6c727..33033e8 100644 --- a/components/form/admin/types/radio.type.tsx +++ b/components/form/admin/types/radio.type.tsx @@ -29,7 +29,7 @@ export const RadioType: React.FC = props => { sm: { offset: index === 0 ? 0 : 6 }, }} labelCol={{ span: 6 }} - label={index === 0 ? 'Options' : ''} + label={index === 0 ? t('type:radio:options') : ''} key={field.key} > @@ -39,7 +39,7 @@ export const RadioType: React.FC = props => { name={[field.name, 'title']} style={{marginBottom: 0}} > - + @@ -48,15 +48,15 @@ export const RadioType: React.FC = props => { name={[field.name, 'value']} style={{marginBottom: 0}} rules={[ - { required: true, message: 'Please provide a value' } + { required: true, message: t('validation:valueRequired') } ]} > - + @@ -72,7 +72,9 @@ export const RadioType: React.FC = props => { + > + {t('type:radio:addOption')} + ) diff --git a/components/form/admin/types/rating.type.tsx b/components/form/admin/types/rating.type.tsx index e0efbfc..af8fa7e 100644 --- a/components/form/admin/types/rating.type.tsx +++ b/components/form/admin/types/rating.type.tsx @@ -13,7 +13,7 @@ export const RatingType: React.FC = props => { label={t('type:rating:default')} name={[props.field.name, 'value']} labelCol={{ span: 6 }} - extra={'Click again to remove default value'} + extra={t('type:rating.clearNote')} > = props => { return ( diff --git a/components/structure.tsx b/components/structure.tsx index b44b5f6..efd1512 100644 --- a/components/structure.tsx +++ b/components/structure.tsx @@ -1,9 +1,11 @@ import {CaretDownOutlined, UserOutlined} from '@ant-design/icons' import {MenuFoldOutlined, MenuUnfoldOutlined} from '@ant-design/icons/lib' -import {Dropdown, Layout, Menu, PageHeader, Spin, Tag} from 'antd' +import {Dropdown, Layout, Menu, PageHeader, Select, Spin, Tag} from 'antd' import Link from 'next/link' import {useRouter} from 'next/router' import React, {FunctionComponent} from 'react' +import {useTranslation} from 'react-i18next' +import {languages} from '../i18n' import {sideMenu, SideMenuElement} from './sidemenu' import {useWindowSize} from './use.window.size' import {clearAuth} from './with.auth' @@ -32,6 +34,7 @@ interface Props { } const Structure: FunctionComponent = (props) => { + const { t, i18n } = useTranslation() const size = useWindowSize() const [userMenu, setUserMenu] = React.useState(false) const [open, setOpen] = React.useState() @@ -120,7 +123,7 @@ const Structure: FunctionComponent = (props) => { } return ( - +
= (props) => { maxHeight: '100%', overflow: 'auto', }} + className={'sidemenu'} > setSelected(s.keyPath)} @@ -192,11 +197,19 @@ const Structure: FunctionComponent = (props) => { mode="inline" selectable={false} > - + + + + Version: {process.env.version} diff --git a/i18n.ts b/i18n.ts index 2cc37e0..1dc3c32 100644 --- a/i18n.ts +++ b/i18n.ts @@ -14,5 +14,7 @@ i18n defaultNS: 'common', react: { useSuspense: process.browser, + transSupportBasicHtmlNodes: true, + transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'em', 'u'], } }) diff --git a/locales/de/admin.ts b/locales/de/admin.ts new file mode 100644 index 0000000..32404bf --- /dev/null +++ b/locales/de/admin.ts @@ -0,0 +1,8 @@ +export const admin = { + home: 'Home', + users: 'Benutzer', + forms: 'Formulare', + submissions: 'Eingaben', + profile: 'Profil', + username: 'Benutzername', +} diff --git a/locales/de/common.ts b/locales/de/common.ts new file mode 100644 index 0000000..278b65b --- /dev/null +++ b/locales/de/common.ts @@ -0,0 +1,7 @@ +export const common = { + logout: 'Abmelden', + login: "Anmelden", + register: "Benutzer erstellen", + recover: 'Passwort vergessen', + admin: "Administration", +} diff --git a/locales/de/form.ts b/locales/de/form.ts new file mode 100644 index 0000000..52cb68a --- /dev/null +++ b/locales/de/form.ts @@ -0,0 +1,97 @@ +export const form = { + building: 'Formular wird aufgebaut', + submitted: 'Vielen dank für ihre Eingaben!', + restart: 'Formular neu starten', + loading: 'Formular wird geladen', + mange: 'Formular "{{title}}" bearbeiten', + new: 'Neues Formular', + created: 'Formular Erstellt', + creationError: 'Formular konnte nicht erstellt werden', + create: 'Neues Formular erstellen', + createNow: 'Jetzt Anlegen', + baseDataTab: 'Basis Daten', + selfNotificationsTab: 'Benachrichtigungen für Verwalter', + respondentNotificationsTab: 'Benarichtigungen für Nutzer', + updated: 'Formular aktualisiert', + updateError: 'Formular konnte nicht aktualisiert werden', + updateNow: 'Speichern', + designTab: 'Design', + startPageTab: 'Eröffnungs Seite', + endPageTab: 'Abschluss Seite', + confirmDelete: 'Wollen sie dieses Formular mit allen Eintragungen löschen?', + deleted: 'Formular gelöscht', + deleteError: 'Formular konnte nicht gelöscht werden', + deleteNow: 'Jetzt löschen!', + row: { + isLive: 'Öffentlich', + title: 'Titel', + admin: 'Verwalter', + language: 'Sprache', + created: 'Erstellt', + lastModified: 'Letzte Änderung', + menu: '' + }, + baseData: { + isLive: 'Öffentlich', + title: 'Titel', + language: 'Sprache', + showFooter: 'Fußzeile anzeigen', + }, + design: { + font: 'Schriftart', + backgroundColor: 'Hintergrund Farbe', + questionColor: 'Fragen Farbe', + answerColor: 'Antworten Farbe', + buttonColor: 'Aktions Farbe', + buttonActiveColor: 'Aktive Aktion Farbe', + buttonTextColor: 'Aktion Schrift Farbe', + }, + endPage: { + show: 'Anzeigen', + continueButtonText: 'Weiter Text', + paragraph: 'Paragraf', + title: 'Titel', + buttons: 'Aktionen', + url: 'Url', + text: 'Text', + action: 'Aktion', + bgColor: 'Hintergrund Farbe', + activeColor: 'Aktive Farbe', + color: 'Text Farbe', + addButton: 'Aktion hinzufügen', + }, + startPage: { + show: 'Anzeigen', + continueButtonText: 'Weiter Text', + paragraph: 'Paragraf', + title: 'Titel', + buttons: 'Aktionen', + url: 'Url', + text: 'Text', + action: 'Aktion', + bgColor: 'Hintergrund Farbe', + activeColor: 'Aktive Farbe', + color: 'Text Farbe', + addButton: 'Aktion hinzufügen', + }, + respondentNotifications: { + enabled: 'Aktiv', + subject: 'Betreff', + htmlTemplate: 'HTML Template', + htmlTemplateInfo: 'Sie können auch MJML verwenden um das Template zu gestalten', + toField: 'Empfänger E-Mail', + toFieldInfo: 'Formular E-Mail Feld für Benachrichtigung', + fromEmail: 'Absender E-Mail', + fromEmailInfo: 'Der E-Mail Server muss den versand von dieser E-Mail zulassen', + }, + selfNotifications: { + enabled: 'Aktiv', + subject: 'Betreff', + htmlTemplate: 'HTML Template', + htmlTemplateInfo: 'Sie können auch MJML verwenden um das Template zu gestalten', + toEmail: 'Empfänger E-Mail', + toEmailInfo: 'Als Standard wird die E-Mail des Verwalters verwendet', + fromField: 'Absender E-Mail', + fromFieldInfo: 'Formular E-Mail Feld für Benachrichtigung, wird as Reply-To gesetzt', + }, +} diff --git a/locales/de/index.ts b/locales/de/index.ts index b18ef03..bc5232f 100644 --- a/locales/de/index.ts +++ b/locales/de/index.ts @@ -1 +1,27 @@ -export const de = {} +import {admin} from './admin' +import {common} from './common' +import {form} from './form' +import language from './language' +import {login} from './login' +import {profile} from './profile' +import {register} from './register' +import {statistic} from './statistic' +import {submission} from './submission' +import {type} from './type' +import {user} from './user' +import {validation} from './validation' + +export const de = { + admin, + common, + form, + language, + login, + profile, + register, + statistic, + submission, + type, + user, + validation, +} diff --git a/locales/de/language.ts b/locales/de/language.ts new file mode 100644 index 0000000..53af018 --- /dev/null +++ b/locales/de/language.ts @@ -0,0 +1,8 @@ +export default { + en: 'English', + de: 'Deutsch', + cn: '繁體中文', + es: 'Español', + fr: 'Français', + it: 'Italiano', +} diff --git a/locales/de/login.ts b/locales/de/login.ts new file mode 100644 index 0000000..0fb902a --- /dev/null +++ b/locales/de/login.ts @@ -0,0 +1,7 @@ +export const login = { + welcomeBack: 'Willkomen zurück!', + invalidLoginCredentials: 'Benutzername oder Passwort ist falsch', + usernamePlaceholder: 'Benutzername', + passwordPlaceholder: 'Passwort', + loginNow: 'Jetzt Anmelden', +} diff --git a/locales/de/profile.ts b/locales/de/profile.ts new file mode 100644 index 0000000..ccbf3e6 --- /dev/null +++ b/locales/de/profile.ts @@ -0,0 +1,10 @@ +export const profile = { + updated: 'Profil Aktualisieren', + updateError: 'Profil konnte nicht aktualisiert werden', + updateNow: 'Speichern', + language: 'Sprache', + email: 'E-Mail', + username: 'Benutzername', + firstName: 'Vorname', + lastName: 'Nachname', +} diff --git a/locales/de/register.ts b/locales/de/register.ts new file mode 100644 index 0000000..8123fd0 --- /dev/null +++ b/locales/de/register.ts @@ -0,0 +1,6 @@ +export const register = { + welcome: 'Willkommen, bitte bestätige noch deine E-Mail', + credentialsAlreadyInUse: 'Deine Daten werden bereits verwendet!', + registerNow: 'Jetzt Registrieren', + gotoLogin: 'Sie haben schon einen Account? Weiter zur Anmeldung', +} diff --git a/locales/de/statistic.ts b/locales/de/statistic.ts new file mode 100644 index 0000000..8ef69b1 --- /dev/null +++ b/locales/de/statistic.ts @@ -0,0 +1,5 @@ +export const statistic = { + 'total-forms': 'Anzahl der Formulare', + 'total-users': 'Anzahl der Benutzer', + 'total-submissions': 'Anzahl der Eingaben', +} diff --git a/locales/de/submission.ts b/locales/de/submission.ts new file mode 100644 index 0000000..4afaefb --- /dev/null +++ b/locales/de/submission.ts @@ -0,0 +1,16 @@ +export const submission = { + progress: 'Fortschritt', + created: 'Erstellt', + lastModified: 'Letzte Änderung', + submission: 'Eingabe', + add: 'Neue Eingabe starten', + edit: 'Formular bearbeiten', + field: 'Feld', + value: 'Wert', + country: 'Land', + city: 'Stadt', + device: { + type: 'Geräte Typ', + name: 'Geräte Name', + } +} diff --git a/locales/de/type.ts b/locales/de/type.ts new file mode 100644 index 0000000..ee3d707 --- /dev/null +++ b/locales/de/type.ts @@ -0,0 +1,65 @@ +export const type = { + deleteNow: 'Feld löschen', + confirmDelete: 'Wollen sie das Feld wirklich löschen? Bitte beachten sie das es keine Referenzen auf das Feld gibt!', + title: 'Titel', + description: 'Beschreibung', + required: 'Pflichtfeld', + requiredInfo: 'Falls verpflichtend sollte ein Standard Wert gesetzt sein damit Nutzer fortfahren können!', + date: { + name: 'Datum', + default: 'Standard Dateum', + min: 'Ältest mögliche Datum', + max: 'Neuest mögliche Datum', + }, + dropdown: { + name: 'Auswahl Liste', + default: 'Standard Wert', + options: 'Auswahl', + titlePlaceholder: 'Titel', + valuePlaceholder: 'Wert', + removeOption: 'Entfernen', + addOption: 'Auswahl hinzufügen', + }, + email: { + name: 'E-Mail', + default: 'Standard E-Mail', + }, + hidden: { + name: 'Versteckt', + default: 'Standard Wert', + }, + link: { + name: 'URL', + default: 'Standard Url', + }, + number: { + name: 'Zahl', + default: 'Standard Zahl', + }, + radio: { + name: 'Knopf Auswahl Liste', + default: 'Standard Wert', + options: 'Auswahl', + titlePlaceholder: 'Titel', + valuePlaceholder: 'Wert', + removeOption: 'Entfernen', + addOption: 'Auswahl hinzufügen', + }, + rating: { + name: 'Bewertung', + default: 'Standard Bewertung', + clearNote: 'Erneut klicken um Auswahl aufzuheben' + }, + textfield: { + name: 'Einzeiliger Text', + default: 'Standard Wert', + }, + textarea: { + name: 'Mehrzeiliger Text', + default: 'Standard Wert', + }, + yes_no: { + name: 'Ja / Nein', + default: 'Standard Wert', + }, +} diff --git a/locales/de/user.ts b/locales/de/user.ts new file mode 100644 index 0000000..4c65d86 --- /dev/null +++ b/locales/de/user.ts @@ -0,0 +1,18 @@ +export const user = { + confirmDelete: 'Wollen sie diesen Benutzer wirklich löschen?', + deleted: 'Benutzer gelöscht', + deleteError: 'Benutzer konnte nicht gelöscht werden', + deleteNow: 'Jetzt löschen!', + loading: 'Benutzer wird geladen', + mange: 'Benutzer "{{email}}" bearbeiten', + row: { + roles: 'Rolle', + email: 'E-Mail', + created: 'Erstellt', + menu: '' + }, + updated: 'Benutzer aktualisiert updated', + updateError: 'Konnte Benutzer nicht aktualisieren', + updateNow: 'Speichern', + baseData: 'Basis Daten', +} diff --git a/locales/de/validation.ts b/locales/de/validation.ts new file mode 100644 index 0000000..5ec89ee --- /dev/null +++ b/locales/de/validation.ts @@ -0,0 +1,15 @@ +export const validation = { + invalidEmail: 'ungültige E-Mail!', + mandatoryFieldsMissing: 'Nicht alle Pflichfelder befüllt', + usernameRequired: 'Bitte einen Benutzernamen angeben', + emailRequired: 'Bitte eine E-Mail angeben', + emailFieldRequired: 'Bitte ein E-Mail Feld auswählen', + languageRequired: 'Bitte eine Sprache angeben', + valueRequired: 'Bitte einen Wert angeben', + invalidUrl: 'ungültige Url', + titleRequired: 'Bitte einen Titel angeben', + templateRequired: 'Bitte ein Template angeben', + subjectRequired: 'Bitte einen Betreff angeben', + passwordRequired: 'Bitte ein Passwort angeben', + passwordMinLength: 'Passwort muss mindestens 5 Zeichen haben!', +} diff --git a/locales/en/form.ts b/locales/en/form.ts index 671e48e..3cb9568 100644 --- a/locales/en/form.ts +++ b/locales/en/form.ts @@ -9,13 +9,15 @@ export const form = { creationError: 'Could not create form', create: 'Create new form', createNow: 'Save', - baseData: 'Base Data', + baseDataTab: 'Base Data', + selfNotificationsTab: 'Self Notifications', + respondentNotificationsTab: 'Respondent Notifications', updated: 'Form updated', updateError: 'Could not update form', updateNow: 'Save', - design: 'Design', - startPage: 'Start Page', - endPage: 'End Page', + designTab: 'Design', + startPageTab: 'Start Page', + endPageTab: 'End Page', confirmDelete: 'Are you sure delete this form with all submissions?', deleted: 'Form deleted', deleteError: 'could not delete form', @@ -28,5 +30,68 @@ export const form = { created: 'Created', lastModified: 'Last Modified', menu: '' - } + }, + baseData: { + isLive: 'Is Live', + title: 'Title', + language: 'Language', + showFooter: 'Show Footer', + }, + design: { + font: 'Font', + backgroundColor: 'Background Color', + questionColor: 'Question Color', + answerColor: 'Answer Color', + buttonColor: 'Button Color', + buttonActiveColor: 'Button Active Color', + buttonTextColor: 'Button Text Color', + }, + endPage: { + show: 'Show', + continueButtonText: 'Continue Button Text', + paragraph: 'Paragraph', + title: 'Title', + buttons: 'Buttons', + url: 'Url', + text: 'Text', + action: 'Action', + bgColor: 'Background Color', + activeColor: 'Active Color', + color: 'Color', + removeButton: 'Add Button', + }, + startPage: { + show: 'Show', + continueButtonText: 'Continue Button Text', + paragraph: 'Paragraph', + title: 'Title', + buttons: 'Buttons', + url: 'Url', + text: 'Text', + action: 'Action', + bgColor: 'Background Color', + activeColor: 'Active Color', + color: 'Color', + addButton: 'Add Button', + }, + respondentNotifications: { + enabled: 'Enabled', + subject: 'Subject', + htmlTemplate: 'HTML Template', + htmlTemplateInfo: 'You can also use MJML to create your email templates', + toField: 'Email Field', + toFieldInfo: 'Field with Email for receipt', + fromEmail: 'Sender Email', + fromEmailInfo: 'Make sure your mailserver can send from this email', + }, + selfNotifications: { + enabled: 'Enabled', + subject: 'Subject', + htmlTemplate: 'HTML Template', + htmlTemplateInfo: 'You can also use MJML to create your email templates', + toEmail: 'Your Email', + toEmailInfo: 'If not set will send to the admin of the form', + fromField: 'Sender Email', + fromFieldInfo: 'Field with Email, will set the Reply-To header', + }, } diff --git a/locales/en/index.ts b/locales/en/index.ts index 1c26d90..c3d420f 100644 --- a/locales/en/index.ts +++ b/locales/en/index.ts @@ -1,11 +1,13 @@ import {admin} from './admin' import {common} from './common' import {form} from './form' +import language from './language' import {login} from './login' import {profile} from './profile' import {register} from './register' import {statistic} from './statistic' import {submission} from './submission' +import {type} from './type' import {user} from './user' import {validation} from './validation' @@ -13,11 +15,13 @@ export const en = { admin, common, form, + language, login, profile, register, statistic, submission, + type, user, validation, } diff --git a/locales/en/language.ts b/locales/en/language.ts new file mode 100644 index 0000000..53af018 --- /dev/null +++ b/locales/en/language.ts @@ -0,0 +1,8 @@ +export default { + en: 'English', + de: 'Deutsch', + cn: '繁體中文', + es: 'Español', + fr: 'Français', + it: 'Italiano', +} diff --git a/locales/en/login.ts b/locales/en/login.ts index c0e98e2..a93cf5c 100644 --- a/locales/en/login.ts +++ b/locales/en/login.ts @@ -1,9 +1,7 @@ export const login = { - 'welcome-back': 'Welcome back!', - 'invalid-login-credentials': 'username / password are invalid', - 'username-required': 'Please input your username!', - 'username-placeholder': 'Username', - 'password-required': 'Please input your password!', - 'password-placeholder': 'Password', - 'login-now': 'Login Now', + welcomeBack: 'Welcome back!', + invalidLoginCredentials: 'username / password are invalid', + usernamePlaceholder: 'Username', + passwordPlaceholder: 'Password', + loginNow: 'Login Now', } diff --git a/locales/en/register.ts b/locales/en/register.ts index ef929f8..636f825 100644 --- a/locales/en/register.ts +++ b/locales/en/register.ts @@ -1,8 +1,6 @@ export const register = { welcome: 'Welcome, please also confirm your email', - 'credentials-already-in-use': 'Some data already in use!', - 'password-min-length': 'Must be longer than or equal to 5 characters!', - 'email-required': 'Please input your email!', - 'register-now': 'Register Now', - 'goto-login': 'Have an account? Go to login', + 'credentialsAlreadyInUse': 'Some data already in use!', + 'registerNow': 'Register Now', + 'gotoLogin': 'Have an account? Go to login', } diff --git a/locales/en/type.ts b/locales/en/type.ts index ef3620e..de2b5bc 100644 --- a/locales/en/type.ts +++ b/locales/en/type.ts @@ -1,10 +1,18 @@ export const type = { + deleteNow: 'Delete Field', + confirmDelete: 'Really remove this field? Check that it is not referenced anywhere!', + title: 'Title', + description: 'Description', + required: 'Required', + requiredInfo: 'If required, default value must be set to enable users to submit form!', date: { + name: 'Date', default: 'Default Date', min: 'Min Date', max: 'Max Date', }, dropdown: { + name: 'Dropdown', default: 'Default Value', options: 'Options', titlePlaceholder: 'Title', @@ -13,30 +21,45 @@ export const type = { addOption: 'Add Option', }, email: { + name: 'Email', default: 'Default Email', }, hidden: { + name: 'Hidden', default: 'Default Value', }, link: { + name: 'URL', default: 'Default Link', }, number: { + name: 'Number', default: 'Default Number', }, radio: { + name: 'Radio Switch', default: 'Default Value', + options: 'Options', + titlePlaceholder: 'Title', + valuePlaceholder: 'Value', + removeOption: 'Remove', + addOption: 'Add Option', }, rating: { + name: 'Rating', default: 'Default Value', + clearNote: 'Click again to remove the default value' }, - text: { + textfield: { + name: 'Text Line', default: 'Default Value', }, textarea: { + name: 'Text Area', default: 'Default Value', }, yes_no: { + name: 'Yes / No', default: 'Default Value', }, } diff --git a/locales/en/user.ts b/locales/en/user.ts index 6af8223..e0ae9b5 100644 --- a/locales/en/user.ts +++ b/locales/en/user.ts @@ -11,8 +11,8 @@ export const user = { created: 'Created', menu: '' }, - updated: 'Form updated', - updateError: 'Could not update form', + updated: 'User updated', + updateError: 'Could not update user', updateNow: 'Save', baseData: 'Base Data', } diff --git a/locales/en/validation.ts b/locales/en/validation.ts index a7cf08a..84e96ba 100644 --- a/locales/en/validation.ts +++ b/locales/en/validation.ts @@ -3,7 +3,13 @@ export const validation = { mandatoryFieldsMissing: 'Mandatory fields missing', usernameRequired: 'Please provide a Username', emailRequired: 'Please provide an Email', + emailFieldRequired: 'Please select an Email Field', languageRequired: 'Please select a Language', valueRequired: 'Please provide a Value', invalidUrl: 'Must be a valid URL', + titleRequired: 'Please provide a title', + templateRequired: 'Please provide a template', + subjectRequired: 'Please provide a subject', + passwordRequired: 'Please input your password!', + passwordMinLength: 'Must be longer than or equal to 5 characters!', } diff --git a/pages/admin/forms/[id]/index.tsx b/pages/admin/forms/[id]/index.tsx index bf45a75..70a09ad 100644 --- a/pages/admin/forms/[id]/index.tsx +++ b/pages/admin/forms/[id]/index.tsx @@ -153,27 +153,27 @@ const Index: NextPage = () => { - - + + - - + + diff --git a/pages/admin/forms/create.tsx b/pages/admin/forms/create.tsx index c094820..37afb9f 100644 --- a/pages/admin/forms/create.tsx +++ b/pages/admin/forms/create.tsx @@ -79,7 +79,7 @@ const Create: NextPage = () => { - + diff --git a/pages/admin/forms/index.tsx b/pages/admin/forms/index.tsx index 08dd7c3..e21940e 100644 --- a/pages/admin/forms/index.tsx +++ b/pages/admin/forms/index.tsx @@ -89,6 +89,7 @@ const Index: NextPage = () => { { title: t('form:row.language'), dataIndex: 'language', + render: lang => t(`language:${lang}`) }, { title: t('form:row.created'), diff --git a/pages/admin/profile.tsx b/pages/admin/profile.tsx index 0064de6..5c62449 100644 --- a/pages/admin/profile.tsx +++ b/pages/admin/profile.tsx @@ -129,7 +129,7 @@ const Profile: NextPage = () => { ]} > diff --git a/pages/form/[id]/index.tsx b/pages/form/[id]/index.tsx index 9a692a2..b561ec9 100644 --- a/pages/form/[id]/index.tsx +++ b/pages/form/[id]/index.tsx @@ -7,7 +7,7 @@ import {LoadingPage} from 'components/loading.page' import {FORM_QUERY, FormQueryData, FormQueryVariables} from 'graphql/query/form.query' import {NextPage} from 'next' import {useRouter} from 'next/router' -import React, {useState} from 'react' +import React, {useEffect, useState} from 'react' import {useTranslation} from 'react-i18next' import Swiper from 'react-id-swiper' import {ReactIdSwiperProps} from 'react-id-swiper/lib/types' @@ -19,7 +19,7 @@ interface Props { } const Index: NextPage = () => { - const { t } = useTranslation() + const { t, i18n } = useTranslation() const router = useRouter() const id = router.query.id as string const [swiper, setSwiper] = useState(null) @@ -31,6 +31,17 @@ const Index: NextPage = () => { } }) + useEffect(() => { + // check form language to switch to! + if (!data) { + return + } + + if (i18n.language !== data.form.language) { + i18n.changeLanguage(data.form.language) + } + }, [data]) + if (loading) { return ( diff --git a/pages/login/index.tsx b/pages/login/index.tsx index ca0f956..8e330e5 100644 --- a/pages/login/index.tsx +++ b/pages/login/index.tsx @@ -30,11 +30,11 @@ const Index: NextPage = () => { result.data.tokens.refresh ) - message.success(t('login:welcome-back')) + message.success(t('login:welcomeBack')) router.push('/admin') } catch (e) { - message.error(t('login:invalid-login-credentials')) + message.error(t('login:invalidLoginCredentials')) } setLoading(false) @@ -71,21 +71,21 @@ const Index: NextPage = () => { @@ -96,7 +96,7 @@ const Index: NextPage = () => { htmlType="submit" block > - {t('login:login-now')} + {t('login:loginNow')} diff --git a/pages/register.tsx b/pages/register.tsx index d9c2410..28a2780 100644 --- a/pages/register.tsx +++ b/pages/register.tsx @@ -38,7 +38,7 @@ const Register: NextPage = () => { router.push('/') } catch (e) { - message.error(t('register:credentials-already-in-use')) + message.error(t('register:credentialsAlreadyInUse')) setLoading(false) } } @@ -74,18 +74,18 @@ const Register: NextPage = () => { @@ -98,13 +98,13 @@ const Register: NextPage = () => { @@ -115,7 +115,7 @@ const Register: NextPage = () => { htmlType="submit" block > - {t('register:register-now')} + {t('register:registerNow')} @@ -131,7 +131,7 @@ const Register: NextPage = () => { type={'link'} ghost > - {t('register:goto-login')} + {t('register:gotoLogin')}