@bottlebooks/valid-values 1.2.0 → 1.2.1

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/core/translate.d.ts +1 -1
  3. package/dist/core/translate.d.ts.map +1 -1
  4. package/dist/core/translate.js +25 -7
  5. package/dist/main.js +21 -21
  6. package/dist/validValues/country.d.ts +6 -1
  7. package/dist/validValues/country.d.ts.map +1 -1
  8. package/dist/validValues/country.js +2 -149
  9. package/dist/validValues/designation.d.ts +0 -115
  10. package/dist/validValues/designation.d.ts.map +1 -1
  11. package/dist/validValues/subregion.d.ts +0 -2
  12. package/dist/validValues/subregion.d.ts.map +1 -1
  13. package/dist/validValues/subregion.js +1385 -2770
  14. package/dist/validValues/types/ValidValueDefinition.d.ts +1 -1
  15. package/dist/validValues/types/ValidValueDefinition.d.ts.map +1 -1
  16. package/package.json +2 -2
  17. package/src/core/translate.ts +33 -9
  18. package/src/locales/po/bg.po +1542 -1542
  19. package/src/locales/po/de.po +1542 -1542
  20. package/src/locales/po/ee.po +1542 -1542
  21. package/src/locales/po/en.po +1542 -1542
  22. package/src/locales/po/es.po +1542 -1542
  23. package/src/locales/po/fi.po +1542 -1542
  24. package/src/locales/po/fr.po +1542 -1542
  25. package/src/locales/po/hr.po +1542 -1542
  26. package/src/locales/po/hu.po +1542 -1542
  27. package/src/locales/po/it.po +1542 -1542
  28. package/src/locales/po/lt.po +1542 -1542
  29. package/src/locales/po/lv.po +1542 -1542
  30. package/src/locales/po/mt.po +1542 -1542
  31. package/src/locales/po/nl.po +1542 -1542
  32. package/src/locales/po/pl.po +1542 -1542
  33. package/src/locales/po/pt.po +1542 -1542
  34. package/src/locales/po/ro.po +1542 -1542
  35. package/src/locales/po/se.po +1542 -1542
  36. package/src/locales/po/si.po +1542 -1542
  37. package/src/locales/po/sk.po +1542 -1542
  38. package/src/main.ts +16 -13
  39. package/src/validValues/country.ts +7 -148
  40. package/src/validValues/designation.ts +0 -5
  41. package/src/validValues/subregion.ts +1 -1387
  42. package/src/validValues/types/ValidValueDefinition.ts +1 -1
  43. package/dist/validValues/types/Country.js +0 -5
  44. package/src/validValues/types/Country.ts +0 -39
@@ -11,7 +11,7 @@ export interface ValidValueDefinition {
11
11
  *
12
12
  * Define it using `defineMessage()` from @lingui/macro.
13
13
  */
14
- title?: string | MessageDescriptor;
14
+ title: string | MessageDescriptor;
15
15
  /**
16
16
  * Fields that will never be stored in the database,
17
17
  * because they are not relevant to the frontend rendering.
@@ -1 +1 @@
1
- {"version":3,"file":"ValidValueDefinition.d.ts","sourceRoot":"","sources":["../../../src/validValues/types/ValidValueDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACpC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC;IACnC;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAKN,CAAC;IACF;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,EAAE,CAAC;CACf"}
1
+ {"version":3,"file":"ValidValueDefinition.d.ts","sourceRoot":"","sources":["../../../src/validValues/types/ValidValueDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACpC;;;;OAIG;IACH,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAAC;IAClC;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAKN,CAAC;IACF;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,EAAE,CAAC;CACf"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@bottlebooks/valid-values",
3
3
  "description": "The Bottlebooks lookup values, defined globally.",
4
4
  "private": false,
5
- "version": "1.2.0",
5
+ "version": "1.2.1",
6
6
  "type": "commonjs",
7
7
  "main": "dist/index.js",
8
8
  "scripts": {
@@ -32,5 +32,5 @@
32
32
  "@babel/core": "^7.15.5",
33
33
  "@lingui/core": "^3.14.0"
34
34
  },
35
- "gitHead": "c633baa84173c2e200b85f3833ef54bfb3809a22"
35
+ "gitHead": "fc6e66bcc86624d21020629f89b961862bbb7f4f"
36
36
  }
@@ -1,16 +1,40 @@
1
1
  import { i18n, MessageDescriptor } from '@lingui/core';
2
2
 
3
- export function translate(message: MessageDescriptor, locale: string) {
4
- i18n.activate(locale);
5
- const translation = i18n._(message);
6
- if (translation === message.id) {
3
+ export function translate(title: MessageDescriptor | string, locale?: string) {
4
+ // if (typeof title === 'string') {
5
+ // return title;
6
+ // }
7
+ const messageId = typeof title === 'string' ? title : title?.id;
8
+ if (!messageId) {
9
+ console.log(
10
+ '%c' + `ERROR: messageId_missing:${JSON.stringify(title)}`,
11
+ 'color: #d0011b;'
12
+ );
13
+ return '';
14
+ }
15
+
16
+ if (!locale) {
17
+ locale = 'en';
18
+ }
19
+ // else {
20
+ // i18n.activate('en');
21
+ // }
22
+ i18n.activate(locale);
23
+
24
+ let translation = i18n._(messageId);
25
+ if (translation === messageId) {
26
+ if (messageId.includes('validValues.')) {
7
27
  console.log(
8
- '%c' + `WARNING: translation_missing:${message.id}:${locale}`,
28
+ '%c' + `ERROR: translation_missing:${messageId}:${locale}`,
9
29
  'color: #d0011b;'
10
30
  );
11
- i18n.activate('en');
12
- return i18n._(message) || '';
31
+ return '';
13
32
  }
14
- return translation;
33
+ console.log(
34
+ '%c' + `WARNING: translation==messageId:${messageId}:${locale}`,
35
+ 'color: #d0011b;'
36
+ );
15
37
  }
16
-
38
+
39
+ return translation;
40
+ }