From e6214893e5f7c869a8db388988b8bd255324b491 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Wed, 8 Jan 2020 21:52:55 -0600 Subject: [PATCH] feat(pwa): adds pwa support fix #1711 --- package.json | 1 + public/index.html | 2 +- public/manifest.json | 8 ++++---- src/__tests__/patients/patients-slice.test.ts | 5 +---- src/i18n.js | 14 +++++++++----- src/index.tsx | 3 ++- .../en => src/locales/en-US}/translation.json | 2 +- 7 files changed, 19 insertions(+), 16 deletions(-) rename {public/locales/en => src/locales/en-US}/translation.json (95%) diff --git a/package.json b/package.json index 012b82ff11..dad2be8bbe 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "commit": "npx git-cz", "start": "react-scripts start", "build": "react-scripts build", + "start:serve": "npm run build && serve -s build", "prepublishOnly": "npm run build", "test": "react-scripts test --detectOpenHandles", "test:ci": "cross-env CI=true react-scripts test", diff --git a/public/index.html b/public/index.html index d3199fe4f5..d9d7dd210f 100644 --- a/public/index.html +++ b/public/index.html @@ -4,7 +4,7 @@ - + { beforeEach(() => { jest.resetAllMocks() @@ -130,7 +127,7 @@ describe('patients slice', () => { expect(mockedComponents.Toast).toHaveBeenCalledWith( 'success', 'Success!', - `patients.successfullyCreated ${expectedGivenName} ${expectedFamilyName} ${expectedSuffix}`, + `Successfully created patient ${expectedGivenName} ${expectedFamilyName} ${expectedSuffix}`, ) }) }) diff --git a/src/i18n.js b/src/i18n.js index c384329296..648c163a6a 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -1,12 +1,16 @@ import i18n from 'i18next' -import Backend from 'i18next-xhr-backend' import LanguageDetector from 'i18next-browser-languagedetector' import { initReactI18next } from 'react-i18next' +import translationEN from './locales/en-US/translation' + +const resources = { + en: { + translation: translationEN, + }, +} + i18n - // load translation using xhr -> see /public/locales - // learn more: https://github.com/i18next/i18next-xhr-backend - .use(Backend) // detect user language // learn more: https://github.com/i18next/i18next-browser-languageDetector .use(LanguageDetector) @@ -17,7 +21,7 @@ i18n .init({ fallbackLng: 'en', debug: true, - + resources, interpolation: { escapeValue: false, // not needed for react as it escapes by default }, diff --git a/src/index.tsx b/src/index.tsx index 003742a69b..c72566a31b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -11,4 +11,5 @@ ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: https://bit.ly/CRA-PWA -serviceWorker.unregister() +serviceWorker.register() +serviceWorker.register({}) diff --git a/public/locales/en/translation.json b/src/locales/en-US/translation.json similarity index 95% rename from public/locales/en/translation.json rename to src/locales/en-US/translation.json index 73872b2c8f..b6d2495541 100644 --- a/public/locales/en/translation.json +++ b/src/locales/en-US/translation.json @@ -7,7 +7,7 @@ "viewPatients": "View Patients", "viewPatient": "View Patient", "newPatient": "New Patient", - "successfullyCreated": "Successfully created patient " + "successfullyCreated": "Successfully created patient" }, "patient": { "suffix": "Suffix",