Skip to content

Commit 48c022c

Browse files
add a string directing to beta.apertium.org (#483)
**Description:** This PR addresses issue #361 and also builds upon and supersedes the changes proposed in PR #422. **Changes Made:** - Modified `config.ts` by adding `showMoreLanguagesLink` and specified its type as `boolean` in `types.ts`. Also, added `more_languages` to `stringReplacements`. - Modified `AboutModal.tsx` by conditionally rendering `more_languages` based on the value of `shouldDisplayString`, either true or false. - In `index.test.tsx`, modified a test to check if, when the About dialog is opened and `showMoreLanguagesLink` is set to `true`, it should render the `more_languages`. Similarly, when `showMoreLanguagesLink` is set to `false` and the About dialog is opened, it should not render the `more_languages`.
1 parent c8c7b20 commit 48c022c

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ export default {
1414

1515
stringReplacements: {
1616
'{{maintainer}}': "<a href='https://wiki.apertium.org/wiki/Apertium' target='_blank' rel='noopener'>Apertium</a>",
17+
'{{more_languages}}': "<a href='https://beta.apertium.org' rel='noreferrer' target='_blank'>beta.apertium.org</a>",
1718
},
19+
showMoreLanguagesLink: false,
1820
} as Config;

src/components/footer/AboutModal.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Modal, { ModalProps } from 'react-bootstrap/Modal';
33
import Col from 'react-bootstrap/Col';
44
import Row from 'react-bootstrap/Row';
55

6+
import { ConfigContext } from '../../context';
67
import { useLocalization } from '../../util/localization';
78

89
import alicanteLogo from './img/logouapp.gif';
@@ -18,6 +19,7 @@ import mineturLogo from './img/logomitc120.jpg';
1819
import prompsitLogo from './img/prompsit150x52.png';
1920

2021
const AboutModal = (props: ModalProps): React.ReactElement => {
22+
const config = React.useContext(ConfigContext);
2123
const { t } = useLocalization();
2224

2325
return (
@@ -28,6 +30,7 @@ const AboutModal = (props: ModalProps): React.ReactElement => {
2830
<Modal.Body>
2931
<p dangerouslySetInnerHTML={{ __html: t('What_Is_Apertium') }} />
3032
<p dangerouslySetInnerHTML={{ __html: t('Maintainer') }} />
33+
{config.showMoreLanguagesLink && <p dangerouslySetInnerHTML={{ __html: t('More_Languages') }} />}
3134

3235
<Row className="lead">
3336
<Col md="6">

src/components/footer/__tests__/index.test.tsx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@ import * as React from 'react';
22
import { getAllByRole, render, screen, waitFor } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
44

5+
import Config from '../../../../config';
6+
import { ConfigContext } from '../../../context';
7+
import { Config as ConfigType } from '../../../types';
8+
59
import Footer from '..';
610

7-
const renderFooter = () => {
11+
const renderFooter = (config: Partial<ConfigType> = {}) => {
812
const wrapRef = React.createRef<HTMLDivElement>();
913
const pushRef = React.createRef<HTMLDivElement>();
1014

1115
render(
12-
<>
13-
<div ref={wrapRef}>
14-
<div ref={pushRef} />
15-
</div>
16-
<Footer pushRef={pushRef} wrapRef={wrapRef} />
17-
</>,
16+
<ConfigContext.Provider value={{ ...Config, ...config }}>
17+
<>
18+
<div ref={wrapRef}>
19+
<div ref={pushRef} />
20+
</div>
21+
<Footer pushRef={pushRef} wrapRef={wrapRef} />
22+
</>
23+
</ConfigContext.Provider>,
1824
);
1925
};
2026

@@ -37,8 +43,18 @@ describe('Footer', () => {
3743
});
3844

3945
describe('navigation buttons', () => {
40-
it('opens about dialog', () => {
41-
renderFooter();
46+
it('opens about dialog and display show more languages link when showMoreLanguagesLink is set to true', () => {
47+
renderFooter({ showMoreLanguagesLink: true });
48+
49+
userEvent.click(screen.getByRole('button', { name: 'About-Default' }));
50+
51+
expect(screen.getByRole('dialog').textContent).toMatchInlineSnapshot(
52+
`"About_Apertium-Default×CloseWhat_Is_Apertium-DefaultApertium-DefaultMore_Languages-Default"`,
53+
);
54+
});
55+
56+
it('opens about dialog and does not display show more languages link when showMoreLanguagesLink is set to false', () => {
57+
renderFooter({ showMoreLanguagesLink: false });
4258

4359
userEvent.click(screen.getByRole('button', { name: 'About-Default' }));
4460

src/strings/eng.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"Help_Improve": "Help us improve Apertium!",
4949
"Contact_Us": "Feel free to contact us if you find a mistake, there's a project you would like to see us work on, or you would like to help out.",
5050
"Maintainer": "This website is maintained by {{maintainer}}.",
51+
"More_Languages": "Looking for more languages? Try {{more_languages}}.",
5152
"About_Title": "About this website",
5253
"Enable_JS_Warning": "This site only works with JavaScript enabled, if you cannot <a href='http://www.enable-javascript.com/' target='_blank' rel='noopener'>enable Javascript</a>, then try the <a href='http://traductor.prompsit.com' target='_blank' rel='noopener'>translators at Prompsit</a>.",
5354
"Not_Found_Error": "<b>404 Error:</b> Sorry, that page doesn't exist anymore!",

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ export type Config = {
2323

2424
subtitle?: string;
2525
subtitleColor?: string;
26+
showMoreLanguagesLink: boolean;
2627
};

0 commit comments

Comments
 (0)