Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding i18n translation files #3

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
729 changes: 9 additions & 720 deletions apps/app/src/app/App.tsx

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions apps/app/src/app/translationComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import { Text } from 'react-native';
import { useTranslation } from 'react-i18next';

export const translationComponent = () => {
const [ t ] = useTranslation();

return (
<Text>{t('PROVE_IDENTITY.TITLE')}</Text>
);
}
15 changes: 15 additions & 0 deletions libs/localization/assets/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
//LANDING PAGE
"LANDING_PAGE": {
"BODY": "Set up your NHS Digital Staff Passport",
"BUTTON": "Continue"
},
//PROVE IDENTITY
"PROVE_IDENTITY": {
"TITLE": "NHS Digital Staff Passport",
"CARD": {
"HEADER": "Prove who you are to get full access",
"BODY": "You'll need to prove your identity before you can use NHS Digital Staff Passport"
}
}
}
1 change: 1 addition & 0 deletions libs/localization/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './lib/localization';
export * from './lib/TranslationProvider';
6 changes: 6 additions & 0 deletions libs/localization/src/lib/TranslationProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { I18nextProvider, I18nextProviderProps } from 'react-i18next';
import { i18n } from './i18n/i18n';

export const TranslationProvider = ({...props}: Omit<I18nextProviderProps, 'i18n'>) => {
return <I18nextProvider i18n={i18n} {...props} />;
};
22 changes: 22 additions & 0 deletions libs/localization/src/lib/i18n/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import 'intl-pluralrules';
import en from './../../../assets/en.json';

i18n
.use(initReactI18next)
.init({
compatibilityJSON: 'v3',
fallbackLng: 'en',
debug: false,
interpolation: {
escapeValue: false,
},
resources: {
en: {
translation: en,
},
},
});

export {i18n};
4 changes: 3 additions & 1 deletion libs/localization/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noPropertyAccessFromIndexSignature": true
"noPropertyAccessFromIndexSignature": true,
"resolveJsonModule": true,
"esModuleInterop": true
},
"files": [],
"include": [],
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
"module": "esnext",
"lib": ["es2020", "dom"],
"skipLibCheck": true,
"jsx": "react-native",
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@digital-staff-passport/features": ["libs/data-access/src/index.ts"],
"@digital-staff-passport/localization": [
"@data-access": ["libs/data-access/src/index.ts"],
"@localization": [
"libs/localization/src/index.ts"
],
"@digital-staff-passport/ui": ["libs/ui/src/index.ts"]
Expand Down