Skip to content

Commit

Permalink
fixed translation on the plugin tab (PalisadoesFoundation#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
aashimawadhwa authored Mar 2, 2023
1 parent aed9945 commit af10ccc
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 40 deletions.
28 changes: 28 additions & 0 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,33 @@
"saveChanges": "Save Changes",
"cancel": "Cancel",
"enterNameOrganization": "Enter Organization Name"
},
"addOnRegister": {
"addNew": "Add New",
"addPlugin": "Add Plugin",
"pluginName": "Plugin Name",
"creatorName": "Creator Name",
"pluginDesc": "Plugin Description",
"close": "Close",
"register": "Register",
"pName": "Ex: Donations",
"cName": "Ex: john Doe",
"pDesc": "This Plugin enables UI for"
},
"addOnStore": {
"searchName": "Ex: Donations",
"enable": "Enabled",
"disable": "Disabled",
"pHeading": "Plugins",
"install": "Installed",
"available": "Available",
"pMessage": "Plugin does not exists",
"filter": "Filters",
"search": "Search"
},
"addOnEntry": {
"enable": "Enabled",
"install": "Install",
"uninstall": "Uninstall"
}
}
28 changes: 28 additions & 0 deletions public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,33 @@
"saveChanges": "Sauvegarder les modifications",
"cancel": "Annuler",
"enterNameOrganization": "Entrez le nom de l'organisation"
},
"addOnRegister": {
"addNew": "Ajouter nouveau",
"addPlugin": "Ajouter un plug-in",
"pluginName": "Nom du plug-in",
"creatorName": "Creator Name",
"pluginDesc": "Description du plug-in",
"close": "Fermer",
"register": "Enregistrer",
"pName": "Ex : Dons",
"cName": "Ex: Jean Doe",
"pDesc": "Ce plugin active l'interface utilisateur pour"
},
"addOnStore": {
"searchName": "Ex:Des dons ",
"enable": "Activé",
"disable": "Désactivé",
"pHeading": "Plugins",
"install": "Installée",
"available": "Disponible",
"pMessage": "Le plugin n'existe pas",
"filter": "Filtres",
"search": "recherche"
},
"addOnEntry": {
"enable": "Activé",
"install": "Installer",
"uninstall": "désinstaller"
}
}
28 changes: 28 additions & 0 deletions public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,33 @@
"saveChanges": "परिवर्तनों को सुरक्षित करें",
"cancel": "रद्द करना",
"enterNameOrganization": "संगठन का नाम दर्ज करें"
},
"addOnRegister": {
"addNew": "नया जोड़ो",
"addPlugin": "प्लगइन जोड़ें",
"pluginName": "प्लगइन का नाम",
"creatorName": "निर्माता का नाम",
"pluginDesc": "प्लगइन विवरण",
"close": "बंद करना",
"register": "पंजीकरण करवाना",
"pName": "जैसे: दान",
"cName": "जैसे: जॉन डो",
"pDesc": "यह प्लगइन यूआई को सक्षम बनाता है"
},
"addOnStore": {
"searchName": "जैसे: दान",
"enable": "सक्रिय",
"disable": "अक्षम",
"pHeading": "प्लग-इन",
"install": "स्थापित",
"available": "उपलब्ध",
"pMessage": "प्लगइन मौजूद नहीं है",
"filter": "फिल्टर",
"search": "खोज"
},
"addOnEntry": {
"enable": "सक्रिय",
"install": "स्थापित करना",
"uninstall": "स्थापना रद्द करें"
}
}
28 changes: 28 additions & 0 deletions public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,33 @@
"saveChanges": "Guardar cambios",
"cancel": "Cancelar",
"enterNameOrganization": "Ingrese el nombre de la organización"
},
"addOnRegister": {
"addNew": "Agregar nueva",
"addPlugin": "Agregar complemento",
"pluginName": "Nombre del complemento",
"creatorName": "Nombre del creadora",
"pluginDesc": "Descripción del complemento",
"close": "Cerca",
"register": "Registro",
"pName": "Ej: Donaciones",
"cName": "Ej: John Doe",
"pDesc": "Este complemento habilita la interfaz de usuario para"
},
"addOnStore": {
"searchName": "Ej: Donaciones",
"enable": "Activada",
"disable": "Desactivada",
"pHeading": "Complementos",
"install": "Instalada",
"available": "Disponible",
"pMessage": "El complemento no existe",
"filter": "filtros",
"search": "Buscar"
},
"addOnEntry": {
"enable": "Activada",
"install": "Instalar",
"uninstall": "Desinstalar"
}
}
28 changes: 28 additions & 0 deletions public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,33 @@
"saveChanges": "保存更改",
"cancel": "取消",
"enterNameOrganization": "輸入組織名稱"
},
"addOnRegister": {
"addNew": "添新",
"addPlugin": "添加插件",
"pluginName": "插件名称",
"creatorName": "创建者姓名",
"pluginDesc": "插件说明",
"close": "关闭",
"register": "登记",
"pName": "例如:捐赠",
"cName": "例如:约翰·多伊",
"pDesc": "此插件启用 UI"
},
"addOnStore": {
"searchName": "例如:捐赠",
"enable": "启用",
"disable": "残疾人",
"pHeading": "插件",
"install": "已安装",
"available": "可用的",
"pMessage": "插件不存在”",
"filter": "过滤器",
"search": "搜索"
},
"addOnEntry": {
"enable": "启用",
"install": "安装",
"uninstall": "卸载"
}
}
7 changes: 5 additions & 2 deletions src/components/AddOn/core/AddOnEntry/AddOnEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
UPDATE_ORG_STATUS_PLUGIN_MUTATION,
} from 'GraphQl/Mutations/mutations';
import { useMutation } from '@apollo/client';
import { useTranslation } from 'react-i18next';

interface AddOnEntryProps {
id: string;
Expand All @@ -32,6 +33,8 @@ function AddOnEntry({
isInstalled,
getInstalledPlugins,
}: AddOnEntryProps): JSX.Element {
const { t } = useTranslation('translation', { keyPrefix: 'addOnEntry' });

const [buttonLoading, setButtonLoading] = useState(false);
const [switchInProgress] = useState(false);
const [isInstalledLocal, setIsInstalledLocal] = useState(isInstalled);
Expand Down Expand Up @@ -142,7 +145,7 @@ function AddOnEntry({
<Form.Check
type="switch"
id="custom-switch"
label="Enabled"
label={t('enable')}
className={styles.entrytoggle}
// eslint-disable-next-line @typescript-eslint/no-empty-function
onChange={() => {}}
Expand Down Expand Up @@ -176,7 +179,7 @@ function AddOnEntry({
></i>
)}
{/* {installed ? 'Remove' : configurable ? 'Installed' : 'Install'} */}
{isInstalledLocal ? 'Uninstall' : 'Install'}
{isInstalledLocal ? t('uninstall') : t('install')}
</Button>
</Card.Body>
</Card>
Expand Down
26 changes: 8 additions & 18 deletions src/components/AddOn/core/AddOnRegister/AddOnRegister.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,17 @@ describe('Testing AddOnRegister', () => {
</Provider>
</ApolloProvider>
);
userEvent.click(screen.getByRole('button', { name: /add new/i }));
userEvent.type(screen.getByPlaceholderText('Ex. Donations'), 'myplugin');
userEvent.type(
screen.getByPlaceholderText('Ex. This plugin provides UI for ....'),
'test description'
);
userEvent.type(
screen.getByPlaceholderText('Ex. Mr John Doe'),
'test creator'
);
userEvent.click(screen.getByRole('button', { name: /addnew/i }));
userEvent.type(screen.getByPlaceholderText(/pName/i), 'myplugin');
userEvent.type(screen.getByPlaceholderText(/pDesc/i), 'test description');
userEvent.type(screen.getByPlaceholderText(/cName/i), 'test creator');
userEvent.click(screen.getByTestId('addonregister'));
userEvent.click(screen.getByTestId('addonclose'));

expect(screen.getByPlaceholderText('Ex. Donations')).toHaveValue(
'myplugin'
);
expect(
screen.getByPlaceholderText('Ex. This plugin provides UI for ....')
).toHaveValue('test description');
expect(screen.getByPlaceholderText('Ex. Mr John Doe')).toHaveValue(
'test creator'
expect(screen.getByPlaceholderText(/pName/i)).toHaveValue('myplugin');
expect(screen.getByPlaceholderText(/pDesc/i)).toHaveValue(
'test description'
);
expect(screen.getByPlaceholderText(/cName/i)).toHaveValue('test creator');
});
});
23 changes: 13 additions & 10 deletions src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styles from './AddOnRegister.module.css';
import { Button, Form, Modal } from 'react-bootstrap';
import { useMutation } from '@apollo/client';
import { ADD_PLUGIN_MUTATION } from 'GraphQl/Mutations/mutations';
import { useTranslation } from 'react-i18next';

interface AddOnRegisterProps {
id?: string; // OrgId
Expand All @@ -21,6 +22,8 @@ const currentUrl = window.location.href.split('=')[1];
console.log(currentUrl);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element {
const { t } = useTranslation('translation', { keyPrefix: 'addOnRegister' });

const [show, setShow] = useState(false);

const handleClose = () => setShow(false);
Expand Down Expand Up @@ -61,20 +64,20 @@ function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element {
onClick={handleShow}
>
<i className="fa fa-plus"></i>
Add New
{t('addNew')}
</Button>

<Modal show={show} onHide={handleClose}>
<Modal.Header closeButton>
<Modal.Title>Add Plugin</Modal.Title>
<Modal.Title> {t('addPlugin')}</Modal.Title>
</Modal.Header>
<Modal.Body>
<Form>
<Form.Group className="mb-3" controlId="registerForm.PluginName">
<Form.Label>Plugin Name</Form.Label>
<Form.Label>{t('pluginName')}</Form.Label>
<Form.Control
type="text"
placeholder="Ex. Donations"
placeholder={t('pName')}
autoComplete="off"
required
value={formState.pluginName}
Expand All @@ -87,10 +90,10 @@ function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element {
/>
</Form.Group>
<Form.Group className="mb-3" controlId="registerForm.PluginName">
<Form.Label>Creator Name</Form.Label>
<Form.Label>{t('creatorName')}</Form.Label>
<Form.Control
type="text"
placeholder="Ex. Mr John Doe"
placeholder={t('cName')}
autoComplete="off"
required
value={formState.pluginCreatedBy}
Expand All @@ -103,12 +106,12 @@ function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element {
/>
</Form.Group>
<Form.Group className="mb-3" controlId="registerForm.PluginURL">
<Form.Label>Plugin Description</Form.Label>
<Form.Label>{t('pluginDesc')}</Form.Label>
<Form.Control
// type="text"
rows={3}
as="textarea"
placeholder="Ex. This plugin provides UI for ...."
placeholder={t('pDesc')}
required
value={formState.pluginDesc}
onChange={(e) => {
Expand All @@ -127,14 +130,14 @@ function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element {
onClick={handleClose}
data-testid="addonclose"
>
Close
{t('close')}
</Button>
<Button
variant="primary"
onClick={handleRegister}
data-testid="addonregister"
>
Register
{t('register')}
</Button>
</Modal.Footer>
</Modal>
Expand Down
Loading

0 comments on commit af10ccc

Please sign in to comment.