feat: i18n user interface (#40306)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Tom
2020-12-16 02:02:52 -06:00
committed by Mrugesh Mohapatra
parent a60a887e63
commit 3978c6be28
149 changed files with 3408 additions and 1084 deletions

View File

@@ -1,11 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Button } from '@freecodecamp/react-bootstrap';
import { useTranslation } from 'react-i18next';
function BlockSaveButton(props) {
const { t } = useTranslation();
return (
<Button block={true} bsStyle='primary' {...props} type='submit'>
{props.children || 'Save'}
{props.children || t('buttons.save')}
</Button>
);
}

View File

@@ -11,10 +11,10 @@ test('<BlockSaveButton /> snapshot', () => {
expect(container).toMatchSnapshot();
});
test('Button text should default to "Save"', () => {
test('Button text should default to the correct translation key', () => {
const { getByRole } = render(<BlockSaveButton />);
expect(getByRole('button')).toHaveTextContent('Save');
expect(getByRole('button')).toHaveTextContent('buttons.save');
});
test('Button text should match "children"', () => {

View File

@@ -6,7 +6,7 @@ exports[`<BlockSaveButton /> snapshot 1`] = `
class="btn btn-primary btn-block"
type="submit"
>
Save
buttons.save
</button>
</div>
`;