@hedia/recommendation-screen 2.1.34-alpha.13 → 2.1.34-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedia/recommendation-screen",
3
- "version": "2.1.34-alpha.13",
3
+ "version": "2.1.34-alpha.14",
4
4
  "description": "Hedia Recommendation Screen for Bolus and Carbohydrates",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -8,10 +8,9 @@
8
8
  "!dist/src/__tests__"
9
9
  ],
10
10
  "scripts": {
11
- "copy-files": "cp -r ./src/locale/ ./dist/src/locale/",
12
11
  "test": "jest --coverage",
13
12
  "tsc": "tsc --noEmit",
14
- "build": "tsc --build && npm run copy-files",
13
+ "build": "tsc --build && chmod +x copy-files.sh && ./copy-files.sh",
15
14
  "clean": "tsc --build --clean && rm -rf dist/",
16
15
  "build-guards": "ts-auto-guard src/**/[!index]*.ts",
17
16
  "lint": "tslint --project .",
@@ -1,13 +0,0 @@
1
- const fs = require(`fs`);
2
- const path = require(`path`);
3
-
4
- const LOCALE_PATH = `./src/locale`;
5
- // tslint:disable:typedef
6
- const dir = fs.readdirSync(LOCALE_PATH).filter((name) => name.length === 2);
7
-
8
- dir.forEach((element) => {
9
- const filePath = path.resolve(LOCALE_PATH, element, `messages.po`);
10
- const fileData = fs.readFileSync(filePath).toString(`utf-8`);
11
- console.log(`Compiling ${filePath}`);
12
- fs.writeFileSync(filePath, fileData.replace(/(msgstr.*?)\\\\n(.*)/g, `$1\\n$2`));
13
- });
@@ -1,42 +0,0 @@
1
- import { Languages } from "@hedia/types";
2
- import { Catalog, I18n, setupI18n } from "@lingui/core";
3
- import moment from "moment";
4
- // tslint:disable-next-line:no-import-side-effect
5
- import "moment/min/locales";
6
-
7
- const languageMap: Record<Languages, Catalog> = {
8
- [Languages.da]: require(`./da/messages.js`),
9
- [Languages.en]: require(`./en/messages.js`),
10
- [Languages.de]: require(`./de/messages.js`),
11
- [Languages.es]: require(`./es/messages.js`),
12
- [Languages.fr]: require(`./fr/messages.js`),
13
- [Languages.it]: require(`./it/messages.js`),
14
- };
15
-
16
- /** Internalisation object containing the translations. Call changeLanguage in order to change the language. */
17
- export const i18n = setupI18n({
18
- language: Languages.en,
19
- catalogs: languageMap,
20
- });
21
-
22
- /**
23
- * Change the language that is used to display text on the recommendation screen.
24
- *
25
- * Steps:
26
- * 1. If the given language is in the language catalog:
27
- * - Call the i18n package’s activate function with language as argument.
28
- * 2. Else:
29
- * - Call the i18n activate function with "English" as argument.
30
- * 3. Return the i18n object.
31
- * @param language The language to switch to.
32
- * @returns Object that represents a i18n configuration for the given language.
33
- */
34
- export function changeLanguage(language: Languages): I18n {
35
- languageMap[language] ? i18n.activate(language) : i18n.activate(Languages.en);
36
- // Temporary way of setting the moment locale to en-gb since we currently identify GB English with "en".
37
- const languagesValues = Object.values(Languages);
38
- const keyOfLanguage = Object.keys(Languages)[languagesValues.indexOf(language)];
39
- const linguiLocale = language === Languages.en ? `en-gb` : keyOfLanguage;
40
- moment.locale(linguiLocale);
41
- return i18n;
42
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes