@stevenkellner/team-conduct-api 1.0.13 → 1.0.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.
Files changed (36) hide show
  1. package/lib/src/functions/fine/add.js +3 -37
  2. package/lib/src/functions/fine/delete.js +3 -37
  3. package/lib/src/functions/fine/update.js +4 -38
  4. package/lib/src/locales/de.json +65 -0
  5. package/lib/src/locales/en.json +65 -0
  6. package/lib/src/types/FineAmount.d.ts +2 -1
  7. package/lib/src/types/FineAmount.js +7 -42
  8. package/lib/src/types/FineTemplateRepetition.d.ts +2 -0
  9. package/lib/src/types/FineTemplateRepetition.js +8 -0
  10. package/lib/src/types/Localization.d.ts +70 -0
  11. package/lib/src/types/Localization.js +123 -0
  12. package/lib/src/types/PayedState.d.ts +1 -0
  13. package/lib/src/types/PayedState.js +5 -0
  14. package/lib/src/types/UserRole.d.ts +1 -0
  15. package/lib/src/types/UserRole.js +11 -0
  16. package/lib/src/types/index.d.ts +1 -0
  17. package/lib/src/types/index.js +1 -0
  18. package/lib/test/localization-utils.d.ts +12 -0
  19. package/lib/test/localization-utils.js +68 -0
  20. package/lib/test/localization.de.test.d.ts +1 -0
  21. package/lib/test/localization.de.test.js +162 -0
  22. package/lib/test/localization.en.test.d.ts +1 -0
  23. package/lib/test/localization.en.test.js +158 -0
  24. package/lib/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +6 -1
  26. package/src/functions/fine/add.ts +5 -5
  27. package/src/functions/fine/delete.ts +4 -5
  28. package/src/functions/fine/update.ts +5 -6
  29. package/src/locales/de.json +63 -28
  30. package/src/locales/en.json +49 -14
  31. package/src/types/FineAmount.ts +7 -9
  32. package/src/types/FineTemplateRepetition.ts +9 -0
  33. package/src/types/Localization.ts +94 -0
  34. package/src/types/PayedState.ts +5 -0
  35. package/src/types/UserRole.ts +11 -0
  36. package/src/types/index.ts +1 -0
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.FineAddFunction = void 0;
37
4
  const firebase_function_1 = require("@stevenkellner/firebase-function");
@@ -40,7 +7,6 @@ const types_1 = require("../../types");
40
7
  const checkAuthentication_1 = require("../../checkAuthentication");
41
8
  const Firestore_1 = require("../../Firestore");
42
9
  const pushNotification_1 = require("../../pushNotification");
43
- const i18n = __importStar(require("i18n"));
44
10
  class FineAddFunction extends firebase_function_1.FirebaseFunction {
45
11
  parametersBuilder = new typescript_common_functionality_1.ObjectTypeBuilder({
46
12
  teamId: types_1.Team.Id.builder,
@@ -61,10 +27,10 @@ class FineAddFunction extends firebase_function_1.FirebaseFunction {
61
27
  await Firestore_1.Firestore.shared.fine(parameters.teamId, parameters.fine.id).set(parameters.fine);
62
28
  person.fineIds.push(parameters.fine.id);
63
29
  await Firestore_1.Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
64
- i18n.setLocale(parameters.configuration.locale);
30
+ types_1.Localization.shared.setLocale(parameters.configuration.locale);
65
31
  await (0, pushNotification_1.pushNotification)(parameters.teamId, parameters.personId, 'new-fine', {
66
- title: i18n.__('notification.fine.new.title', parameters.fine.reason),
67
- body: i18n.__('notification.fine.new.body', parameters.fine.amount.formatted(parameters.configuration))
32
+ title: types_1.Localization.shared.get(key => key.notification.fine.new.title, parameters.fine.reason),
33
+ body: types_1.Localization.shared.get(key => key.notification.fine.new.body, parameters.fine.amount.formatted(parameters.configuration))
68
34
  });
69
35
  }
70
36
  }
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.FineDeleteFunction = void 0;
37
4
  const firebase_function_1 = require("@stevenkellner/firebase-function");
@@ -40,7 +7,6 @@ const typescript_common_functionality_1 = require("@stevenkellner/typescript-com
40
7
  const checkAuthentication_1 = require("../../checkAuthentication");
41
8
  const Firestore_1 = require("../../Firestore");
42
9
  const pushNotification_1 = require("../../pushNotification");
43
- const i18n = __importStar(require("i18n"));
44
10
  class FineDeleteFunction extends firebase_function_1.FirebaseFunction {
45
11
  parametersBuilder = new typescript_common_functionality_1.ObjectTypeBuilder({
46
12
  teamId: types_1.Team.Id.builder,
@@ -61,10 +27,10 @@ class FineDeleteFunction extends firebase_function_1.FirebaseFunction {
61
27
  await Firestore_1.Firestore.shared.fine(parameters.teamId, parameters.id).remove();
62
28
  person.fineIds = person.fineIds.filter(id => id.guidString !== parameters.id.guidString);
63
29
  await Firestore_1.Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
64
- i18n.setLocale(parameters.configuration.locale);
30
+ types_1.Localization.shared.setLocale(parameters.configuration.locale);
65
31
  await (0, pushNotification_1.pushNotification)(parameters.teamId, parameters.personId, 'fine-state-change', {
66
- title: i18n.__('notification.fine.state-change.title'),
67
- body: i18n.__('notification.fine.state-change.body-deleted', fineSnapshot.data.reason, types_1.FineAmount.builder.build(fineSnapshot.data.amount).formatted(parameters.configuration))
32
+ title: types_1.Localization.shared.get(key => key.notification.fine.stateChange.title),
33
+ body: types_1.Localization.shared.get(key => key.notification.fine.stateChange.bodyDeleted, fineSnapshot.data.reason, types_1.FineAmount.builder.build(fineSnapshot.data.amount).formatted(parameters.configuration))
68
34
  });
69
35
  }
70
36
  }
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.FineUpdateFunction = void 0;
37
4
  const Configuration_1 = require("../../types/Configuration");
@@ -41,7 +8,6 @@ const types_1 = require("../../types");
41
8
  const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
42
9
  const checkAuthentication_1 = require("../../checkAuthentication");
43
10
  const Firestore_1 = require("../../Firestore");
44
- const i18n = __importStar(require("i18n"));
45
11
  class FineUpdateFunction extends firebase_function_1.FirebaseFunction {
46
12
  parametersBuilder = new typescript_common_functionality_1.ObjectTypeBuilder({
47
13
  teamId: types_1.Team.Id.builder,
@@ -56,15 +22,15 @@ class FineUpdateFunction extends firebase_function_1.FirebaseFunction {
56
22
  if (!fineSnapshot.exists)
57
23
  throw new firebase_function_1.FunctionsError('not-found', 'Fine not found');
58
24
  await Firestore_1.Firestore.shared.fine(parameters.teamId, parameters.fine.id).set(parameters.fine);
59
- i18n.setLocale(parameters.configuration.locale);
25
+ types_1.Localization.shared.setLocale(parameters.configuration.locale);
60
26
  if (parameters.fine.payedState !== fineSnapshot.data.payedState) {
61
27
  let body;
62
28
  if (parameters.fine.payedState === 'payed')
63
- body = i18n.__('notification.fine.state-change.body-payed', parameters.fine.amount.formatted(parameters.configuration), parameters.fine.reason);
29
+ body = types_1.Localization.shared.get(key => key.notification.fine.stateChange.bodyPayed, parameters.fine.amount.formatted(parameters.configuration), parameters.fine.reason);
64
30
  else
65
- body = i18n.__('notification.fine.state-change.body-unpayed', parameters.fine.reason, parameters.fine.amount.formatted(parameters.configuration));
31
+ body = types_1.Localization.shared.get(key => key.notification.fine.stateChange.bodyUnpayed, parameters.fine.reason, parameters.fine.amount.formatted(parameters.configuration));
66
32
  await (0, pushNotification_1.pushNotification)(parameters.teamId, parameters.personId, 'fine-state-change', {
67
- title: i18n.__('notification.fine.state-change.title'),
33
+ title: types_1.Localization.shared.get(key => key.notification.fine.stateChange.title),
68
34
  body: body
69
35
  });
70
36
  }
@@ -0,0 +1,65 @@
1
+ {
2
+ "notification": {
3
+ "fine": {
4
+ "new": {
5
+ "title": "%s",
6
+ "body": "Du hast eine neue Strafe von %s. Bitte so schnell wie möglich zahlen."
7
+ },
8
+ "reminder": {
9
+ "title": "Du hast noch offene Strafen",
10
+ "body": "Bei dir sind noch %s offen. Bitte so schnell wie möglich zahlen."
11
+ },
12
+ "state-change": {
13
+ "title": "Eine deiner Strafen hat sich geändert",
14
+ "body-payed": "Du hast eine Strafe von %1$s bezahlt (%2$s).",
15
+ "body-unpayed": "%1$s, %2$s ist noch offen.",
16
+ "body-deleted": "%1$s, %2$s wurde gelöscht."
17
+ }
18
+ }
19
+ },
20
+ "fineAmount": {
21
+ "item": {
22
+ "type": {
23
+ "crateOfBeer": "Kasten Bier",
24
+ "crateOfBeer?count=%s": {
25
+ "one": "Ein Kasten Bier",
26
+ "other": "%s Kästen Bier"
27
+ }
28
+ }
29
+ }
30
+ },
31
+ "fineTemplateRepetition": {
32
+ "item": {
33
+ "minute": "Minute",
34
+ "minute?count=%s": {
35
+ "one": "1 Minute",
36
+ "other": "%s Minuten"
37
+ },
38
+ "day": "Tag",
39
+ "day?count=%s": {
40
+ "one": "1 Tag",
41
+ "other": "%s Tage"
42
+ },
43
+ "item": "Teil",
44
+ "item?count=%s": {
45
+ "one": "1 Teil",
46
+ "other": "%s Teile"
47
+ },
48
+ "count": "Anzahl",
49
+ "count?count=%s": {
50
+ "one": "1 mal",
51
+ "other": "%s mal"
52
+ }
53
+ }
54
+ },
55
+ "payedState": {
56
+ "payed": "Bezahlt",
57
+ "notPayed": "Offen"
58
+ },
59
+ "userRole": {
60
+ "personManager": "Personenmanager",
61
+ "fineTemplateManager": "Strafvorlagenmanager",
62
+ "fineManager": "Strafenmanager",
63
+ "teamManager": "Teammanager"
64
+ }
65
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ "notification": {
3
+ "fine": {
4
+ "new": {
5
+ "title": "%s",
6
+ "body": "You have a new fine of %s. Please pay it as soon as possible."
7
+ },
8
+ "reminder": {
9
+ "title": "You still have outstanding fines",
10
+ "body": "You still have %s outstanding. Please pay as soon as possible."
11
+ },
12
+ "state-change": {
13
+ "title": "One of your fines has changed",
14
+ "body-payed": "You have paid a fine of %1$s (%2$s).",
15
+ "body-unpayed": "%1$s, %2$s is still outstanding.",
16
+ "body-deleted": "%1$s, %2$s has been deleted."
17
+ }
18
+ }
19
+ },
20
+ "fineAmount": {
21
+ "item": {
22
+ "type": {
23
+ "crateOfBeer": "Crate of Beer",
24
+ "crateOfBeer?count=%s": {
25
+ "one": "a crate of beer",
26
+ "other": "%s crates of beer"
27
+ }
28
+ }
29
+ }
30
+ },
31
+ "fineTemplateRepetition": {
32
+ "item": {
33
+ "minute": "Minute",
34
+ "minute?count=%s": {
35
+ "one": "1 minute",
36
+ "other": "%s minutes"
37
+ },
38
+ "day": "Day",
39
+ "day?count=%s": {
40
+ "one": "1 day",
41
+ "other": "%s days"
42
+ },
43
+ "item": "Item",
44
+ "item?count=%s": {
45
+ "one": "1 item",
46
+ "other": "%s items"
47
+ },
48
+ "count": "Count",
49
+ "count?count=%s": {
50
+ "one": "1 time",
51
+ "other": "%s times"
52
+ }
53
+ }
54
+ },
55
+ "payedState": {
56
+ "payed": "Paid",
57
+ "notPayed": "Outstanding"
58
+ },
59
+ "userRole": {
60
+ "personManager": "Person Manager",
61
+ "fineTemplateManager": "Fine Template Manager",
62
+ "fineManager": "Fine Manager",
63
+ "teamManager": "Team Manager"
64
+ }
65
+ }
@@ -23,13 +23,14 @@ export declare namespace FineAmount {
23
23
  item: Item.Type;
24
24
  count: number;
25
25
  constructor(item: Item.Type, count: number);
26
- formatted(configuration: Configuration): string;
26
+ formatted(): string;
27
27
  get flatten(): Item.Flatten;
28
28
  }
29
29
  namespace Item {
30
30
  type Type = 'crateOfBeer';
31
31
  namespace Type {
32
32
  const all: Type[];
33
+ function formatted(type: Type): string;
33
34
  }
34
35
  type Flatten = {
35
36
  type: 'item';
@@ -1,41 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.FineAmount = void 0;
37
4
  const MoneyAmount_1 = require("./MoneyAmount");
38
- const i18n = __importStar(require("i18n"));
5
+ const Localization_1 = require("./Localization");
39
6
  var FineAmount;
40
7
  (function (FineAmount) {
41
8
  class Money {
@@ -70,14 +37,8 @@ var FineAmount;
70
37
  this.item = item;
71
38
  this.count = count;
72
39
  }
73
- formatted(configuration) {
74
- const numberFormat = Intl.NumberFormat(configuration.locale, {
75
- minimumFractionDigits: 0,
76
- maximumFractionDigits: 0
77
- });
78
- if (this.count === 1)
79
- return i18n.__(`FineAmount.Item.Type.${this.item}.singular`, numberFormat.format(this.count));
80
- return i18n.__(`FineAmount.Item.Type.${this.item}.plural`, numberFormat.format(this.count));
40
+ formatted() {
41
+ return Localization_1.Localization.shared.getN(key => key.fineAmount.item.type[this.item], this.count);
81
42
  }
82
43
  get flatten() {
83
44
  return {
@@ -92,6 +53,10 @@ var FineAmount;
92
53
  let Type;
93
54
  (function (Type) {
94
55
  Type.all = ['crateOfBeer'];
56
+ function formatted(type) {
57
+ return Localization_1.Localization.shared.get(key => key.fineAmount.item.type[type]);
58
+ }
59
+ Type.formatted = formatted;
95
60
  })(Type = Item.Type || (Item.Type = {}));
96
61
  class TypeBuilder {
97
62
  build(value) {
@@ -3,12 +3,14 @@ export declare class FineTemplateRepetition implements Flattable<FineTemplateRep
3
3
  item: FineTemplateRepetition.Item;
4
4
  maxCount: number | null;
5
5
  constructor(item: FineTemplateRepetition.Item, maxCount: number | null);
6
+ formatted(count: number): string;
6
7
  get flatten(): FineTemplateRepetition.Flatten;
7
8
  }
8
9
  export declare namespace FineTemplateRepetition {
9
10
  type Item = 'minute' | 'day' | 'item' | 'count';
10
11
  namespace Item {
11
12
  const all: Item[];
13
+ function formatted(item: Item): string;
12
14
  const builder: ValueTypeBuilder<Item>;
13
15
  }
14
16
  type Flatten = {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FineTemplateRepetition = void 0;
4
4
  const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
+ const Localization_1 = require("./Localization");
5
6
  class FineTemplateRepetition {
6
7
  item;
7
8
  maxCount;
@@ -9,6 +10,9 @@ class FineTemplateRepetition {
9
10
  this.item = item;
10
11
  this.maxCount = maxCount;
11
12
  }
13
+ formatted(count) {
14
+ return Localization_1.Localization.shared.getN(key => key.fineTemplateRepetition.item[this.item], count);
15
+ }
12
16
  get flatten() {
13
17
  return {
14
18
  item: this.item,
@@ -26,6 +30,10 @@ exports.FineTemplateRepetition = FineTemplateRepetition;
26
30
  'item',
27
31
  'count'
28
32
  ];
33
+ function formatted(item) {
34
+ return Localization_1.Localization.shared.get(key => key.fineTemplateRepetition.item[item]);
35
+ }
36
+ Item.formatted = formatted;
29
37
  Item.builder = new typescript_common_functionality_1.ValueTypeBuilder();
30
38
  })(Item = FineTemplateRepetition.Item || (FineTemplateRepetition.Item = {}));
31
39
  class TypeBuilder {
@@ -0,0 +1,70 @@
1
+ import { Configuration } from './Configuration';
2
+ export declare const localizationKey: {
3
+ notification: {
4
+ fine: {
5
+ new: {
6
+ title: string;
7
+ body: string;
8
+ };
9
+ reminder: {
10
+ title: string;
11
+ body: string;
12
+ };
13
+ stateChange: {
14
+ title: string;
15
+ bodyPayed: string;
16
+ bodyUnpayed: string;
17
+ bodyDeleted: string;
18
+ };
19
+ };
20
+ };
21
+ fineAmount: {
22
+ item: {
23
+ type: {
24
+ crateOfBeer: string;
25
+ };
26
+ };
27
+ };
28
+ fineTemplateRepetition: {
29
+ item: {
30
+ minute: string;
31
+ day: string;
32
+ item: string;
33
+ count: string;
34
+ };
35
+ };
36
+ payedState: {
37
+ payed: string;
38
+ notPayed: string;
39
+ };
40
+ userRole: {
41
+ personManager: string;
42
+ fineTemplateManager: string;
43
+ fineManager: string;
44
+ teamManager: string;
45
+ };
46
+ };
47
+ export declare const localizationNKey: {
48
+ fineAmount: {
49
+ item: {
50
+ type: {
51
+ crateOfBeer: string;
52
+ };
53
+ };
54
+ };
55
+ fineTemplateRepetition: {
56
+ item: {
57
+ minute: string;
58
+ day: string;
59
+ item: string;
60
+ count: string;
61
+ };
62
+ };
63
+ };
64
+ export declare class Localization {
65
+ static readonly shared: Localization;
66
+ private constructor();
67
+ setLocale(locale: Configuration.Locale): void;
68
+ get(getKey: (key: typeof localizationKey) => string, ...args: string[]): string;
69
+ getN(getKey: (key: typeof localizationNKey) => string, count: number): string;
70
+ }
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Localization = exports.localizationNKey = exports.localizationKey = void 0;
37
+ const i18n = __importStar(require("i18n"));
38
+ const Configuration_1 = require("./Configuration");
39
+ exports.localizationKey = {
40
+ notification: {
41
+ fine: {
42
+ new: {
43
+ title: 'notification.fine.new.title',
44
+ body: 'notification.fine.new.body'
45
+ },
46
+ reminder: {
47
+ title: 'notification.fine.reminder.title',
48
+ body: 'notification.fine.reminder.body'
49
+ },
50
+ stateChange: {
51
+ title: 'notification.fine.state-change.title',
52
+ bodyPayed: 'notification.fine.state-change.body-payed',
53
+ bodyUnpayed: 'notification.fine.state-change.body-unpayed',
54
+ bodyDeleted: 'notification.fine.state-change.body-deleted'
55
+ }
56
+ }
57
+ },
58
+ fineAmount: {
59
+ item: {
60
+ type: {
61
+ crateOfBeer: 'fineAmount.item.type.crateOfBeer'
62
+ }
63
+ }
64
+ },
65
+ fineTemplateRepetition: {
66
+ item: {
67
+ minute: 'fineTemplateRepetition.item.minute',
68
+ day: 'fineTemplateRepetition.item.day',
69
+ item: 'fineTemplateRepetition.item.item',
70
+ count: 'fineTemplateRepetition.item.count'
71
+ }
72
+ },
73
+ payedState: {
74
+ payed: 'payedState.payed',
75
+ notPayed: 'payedState.notPayed'
76
+ },
77
+ userRole: {
78
+ personManager: 'userRole.personManager',
79
+ fineTemplateManager: 'userRole.fineTemplateManager',
80
+ fineManager: 'userRole.fineManager',
81
+ teamManager: 'userRole.teamManager'
82
+ }
83
+ };
84
+ exports.localizationNKey = {
85
+ fineAmount: {
86
+ item: {
87
+ type: {
88
+ crateOfBeer: 'fineAmount.item.type.crateOfBeer?count=%s'
89
+ }
90
+ }
91
+ },
92
+ fineTemplateRepetition: {
93
+ item: {
94
+ minute: 'fineTemplateRepetition.item.minute?count=%s',
95
+ day: 'fineTemplateRepetition.item.day?count=%s',
96
+ item: 'fineTemplateRepetition.item.item?count=%s',
97
+ count: 'fineTemplateRepetition.item.count?count=%s'
98
+ }
99
+ }
100
+ };
101
+ class Localization {
102
+ static shared = new Localization();
103
+ constructor() {
104
+ i18n.configure({
105
+ locales: Configuration_1.Configuration.Locale.all,
106
+ defaultLocale: 'en',
107
+ directory: 'src/locales',
108
+ objectNotation: true
109
+ });
110
+ }
111
+ setLocale(locale) {
112
+ i18n.setLocale(locale);
113
+ }
114
+ get(getKey, ...args) {
115
+ const key = getKey(exports.localizationKey);
116
+ return i18n.__(key, ...args);
117
+ }
118
+ getN(getKey, count) {
119
+ const key = getKey(exports.localizationNKey);
120
+ return i18n.__n(key, count);
121
+ }
122
+ }
123
+ exports.Localization = Localization;
@@ -2,5 +2,6 @@ import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality
2
2
  export type PayedState = 'payed' | 'notPayed';
3
3
  export declare namespace PayedState {
4
4
  const all: PayedState[];
5
+ function formatted(state: PayedState): string;
5
6
  const builder: ValueTypeBuilder<PayedState>;
6
7
  }
@@ -2,8 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PayedState = void 0;
4
4
  const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
+ const Localization_1 = require("./Localization");
5
6
  var PayedState;
6
7
  (function (PayedState) {
7
8
  PayedState.all = ['payed', 'notPayed'];
9
+ function formatted(state) {
10
+ return Localization_1.Localization.shared.get(key => key.payedState[state]);
11
+ }
12
+ PayedState.formatted = formatted;
8
13
  PayedState.builder = new typescript_common_functionality_1.ValueTypeBuilder();
9
14
  })(PayedState || (exports.PayedState = PayedState = {}));
@@ -2,5 +2,6 @@ import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality
2
2
  export type UserRole = 'person-manager' | 'fineTemplate-manager' | 'fine-manager' | 'team-manager';
3
3
  export declare namespace UserRole {
4
4
  const all: UserRole[];
5
+ function formatted(role: UserRole): string;
5
6
  const builder: ValueTypeBuilder<UserRole>;
6
7
  }