@stevenkellner/team-conduct-api 1.0.22 → 1.0.24
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/lib/src/functions/fine/add.js +7 -3
- package/lib/src/functions/fine/delete.js +5 -3
- package/lib/src/functions/fine/update.js +9 -6
- package/lib/src/locales/de.d.ts +66 -0
- package/lib/src/locales/de.js +99 -0
- package/lib/src/locales/en.d.ts +66 -0
- package/lib/src/locales/en.js +99 -0
- package/lib/src/types/Configuration.d.ts +3 -2
- package/lib/src/types/Configuration.js +2 -1
- package/lib/src/types/FineAmount.js +3 -3
- package/lib/src/types/FineTemplateRepetition.js +3 -3
- package/lib/src/types/Localization.d.ts +205 -60
- package/lib/src/types/Localization.js +65 -117
- package/lib/src/types/PayedState.js +1 -1
- package/lib/src/types/Pluralization.d.ts +17 -0
- package/lib/src/types/Pluralization.js +33 -0
- package/lib/src/types/UserRole.js +1 -1
- package/lib/src/types/index.d.ts +1 -0
- package/lib/src/types/index.js +1 -0
- package/lib/test/localization-utils.d.ts +0 -11
- package/lib/test/localization-utils.js +5 -49
- package/lib/test/localization.de.test.js +43 -80
- package/lib/test/localization.en.test.js +46 -85
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -10
- package/src/functions/fine/add.ts +7 -3
- package/src/functions/fine/delete.ts +5 -3
- package/src/functions/fine/update.ts +10 -7
- package/src/locales/de.ts +97 -0
- package/src/locales/en.ts +97 -0
- package/src/types/Configuration.ts +4 -3
- package/src/types/FineAmount.ts +3 -3
- package/src/types/FineTemplateRepetition.ts +3 -3
- package/src/types/Localization.ts +67 -83
- package/src/types/PayedState.ts +1 -1
- package/src/types/Pluralization.ts +44 -0
- package/src/types/UserRole.ts +3 -3
- package/src/types/index.ts +1 -0
- package/lib/src/locales/de.json +0 -85
- package/lib/src/locales/en.json +0 -85
- package/src/locales/de.json +0 -85
- package/src/locales/en.json +0 -85
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Pluralization } from '../types/Pluralization';
|
|
2
|
+
|
|
3
|
+
export const localizationDE = {
|
|
4
|
+
notification: {
|
|
5
|
+
fine: {
|
|
6
|
+
new: {
|
|
7
|
+
title: '{{reason}}',
|
|
8
|
+
body: 'Du hast eine neue Strafe von {{amount}}. Bitte so schnell wie möglich zahlen.'
|
|
9
|
+
},
|
|
10
|
+
reminder: {
|
|
11
|
+
title: 'Du hast noch offene Strafen',
|
|
12
|
+
body: 'Bei dir sind noch {{amount}} offen. Bitte so schnell wie möglich zahlen.'
|
|
13
|
+
},
|
|
14
|
+
stateChange: {
|
|
15
|
+
title: 'Eine deiner Strafen hat sich geändert',
|
|
16
|
+
bodyPayed: 'Du hast eine Strafe von {{amount}} bezahlt ({{reason}}).',
|
|
17
|
+
bodyUnpayed: '{{reason}}, {{amount}} ist noch offen.',
|
|
18
|
+
bodyDeleted: '{{reason}}, {{amount}} wurde gelöscht.'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
fineAmount: {
|
|
23
|
+
item: {
|
|
24
|
+
type: {
|
|
25
|
+
crateOfBeer: {
|
|
26
|
+
name: 'Kasten Bier',
|
|
27
|
+
withCount: new Pluralization({
|
|
28
|
+
one: 'Ein Kasten Bier',
|
|
29
|
+
other: '{{count}} Kästen Bier'
|
|
30
|
+
}),
|
|
31
|
+
withoutCount: new Pluralization({
|
|
32
|
+
one: 'Kasten Bier',
|
|
33
|
+
other: 'Kästen Bier'
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
fineTemplateRepetition: {
|
|
40
|
+
item: {
|
|
41
|
+
minute: {
|
|
42
|
+
name: 'Minute',
|
|
43
|
+
withCount: new Pluralization({
|
|
44
|
+
one: '1 Minute',
|
|
45
|
+
other: '{{count}} Minuten'
|
|
46
|
+
}),
|
|
47
|
+
withoutCount: new Pluralization({
|
|
48
|
+
one: 'Minute',
|
|
49
|
+
other: 'Minuten'
|
|
50
|
+
})
|
|
51
|
+
},
|
|
52
|
+
day: {
|
|
53
|
+
name: 'Tag',
|
|
54
|
+
withCount: new Pluralization({
|
|
55
|
+
one: '1 Tag',
|
|
56
|
+
other: '{{count}} Tage'
|
|
57
|
+
}),
|
|
58
|
+
withoutCount: new Pluralization({
|
|
59
|
+
one: 'Tag',
|
|
60
|
+
other: 'Tage'
|
|
61
|
+
})
|
|
62
|
+
},
|
|
63
|
+
item: {
|
|
64
|
+
name: 'Teil',
|
|
65
|
+
withCount: new Pluralization({
|
|
66
|
+
one: '1 Teil',
|
|
67
|
+
other: '{{count}} Teile'
|
|
68
|
+
}),
|
|
69
|
+
withoutCount: new Pluralization({
|
|
70
|
+
one: 'Teil',
|
|
71
|
+
other: 'Teile'
|
|
72
|
+
})
|
|
73
|
+
},
|
|
74
|
+
count: {
|
|
75
|
+
name: 'Anzahl',
|
|
76
|
+
withCount: new Pluralization({
|
|
77
|
+
one: '1 mal',
|
|
78
|
+
other: '{{count}} mal'
|
|
79
|
+
}),
|
|
80
|
+
withoutCount: new Pluralization({
|
|
81
|
+
one: 'mal',
|
|
82
|
+
other: 'mal'
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
payedState: {
|
|
88
|
+
payed: 'Bezahlt',
|
|
89
|
+
notPayed: 'Offen'
|
|
90
|
+
},
|
|
91
|
+
userRole: {
|
|
92
|
+
personManager: 'Personenmanager',
|
|
93
|
+
fineTemplateManager: 'Strafvorlagenmanager',
|
|
94
|
+
fineManager: 'Strafenmanager',
|
|
95
|
+
teamManager: 'Teammanager'
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Pluralization } from '../types/Pluralization';
|
|
2
|
+
|
|
3
|
+
export const localizationEN = {
|
|
4
|
+
notification: {
|
|
5
|
+
fine: {
|
|
6
|
+
new: {
|
|
7
|
+
title: '{{reason}}',
|
|
8
|
+
body: 'You have a new fine of {{amount}}. Please pay it as soon as possible.'
|
|
9
|
+
},
|
|
10
|
+
reminder: {
|
|
11
|
+
title: 'You still have outstanding fines',
|
|
12
|
+
body: 'You still have {{amount}} outstanding. Please pay as soon as possible.'
|
|
13
|
+
},
|
|
14
|
+
stateChange: {
|
|
15
|
+
title: 'One of your fines has changed',
|
|
16
|
+
bodyPayed: 'You have paid a fine of {{amount}} ({{reason}}).',
|
|
17
|
+
bodyUnpayed: '{{reason}}, {{amount}} is still outstanding.',
|
|
18
|
+
bodyDeleted: '{{reason}}, {{amount}} has been deleted.'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
fineAmount: {
|
|
23
|
+
item: {
|
|
24
|
+
type: {
|
|
25
|
+
crateOfBeer: {
|
|
26
|
+
name: 'Crate of Beer',
|
|
27
|
+
withCount: new Pluralization({
|
|
28
|
+
one: 'a crate of beer',
|
|
29
|
+
other: '{{count}} crates of beer'
|
|
30
|
+
}),
|
|
31
|
+
withoutCount: new Pluralization({
|
|
32
|
+
one: 'Crate of Beer',
|
|
33
|
+
other: 'Crates of Beer'
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
fineTemplateRepetition: {
|
|
40
|
+
item: {
|
|
41
|
+
minute: {
|
|
42
|
+
name: 'Minute',
|
|
43
|
+
withCount: new Pluralization({
|
|
44
|
+
one: '1 minute',
|
|
45
|
+
other: '{{count}} minutes'
|
|
46
|
+
}),
|
|
47
|
+
withoutCount: new Pluralization({
|
|
48
|
+
one: 'minute',
|
|
49
|
+
other: 'minutes'
|
|
50
|
+
})
|
|
51
|
+
},
|
|
52
|
+
day: {
|
|
53
|
+
name: 'Day',
|
|
54
|
+
withCount: new Pluralization({
|
|
55
|
+
one: '1 day',
|
|
56
|
+
other: '{{count}} days'
|
|
57
|
+
}),
|
|
58
|
+
withoutCount: new Pluralization({
|
|
59
|
+
one: 'day',
|
|
60
|
+
other: 'days'
|
|
61
|
+
})
|
|
62
|
+
},
|
|
63
|
+
item: {
|
|
64
|
+
name: 'Item',
|
|
65
|
+
withCount: new Pluralization({
|
|
66
|
+
one: '1 item',
|
|
67
|
+
other: '{{count}} items'
|
|
68
|
+
}),
|
|
69
|
+
withoutCount: new Pluralization({
|
|
70
|
+
one: 'item',
|
|
71
|
+
other: 'items'
|
|
72
|
+
})
|
|
73
|
+
},
|
|
74
|
+
count: {
|
|
75
|
+
name: 'Count',
|
|
76
|
+
withCount: new Pluralization({
|
|
77
|
+
one: '1 time',
|
|
78
|
+
other: '{{count}} times'
|
|
79
|
+
}),
|
|
80
|
+
withoutCount: new Pluralization({
|
|
81
|
+
one: 'time',
|
|
82
|
+
other: 'times'
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
payedState: {
|
|
88
|
+
payed: 'Paid',
|
|
89
|
+
notPayed: 'Outstanding'
|
|
90
|
+
},
|
|
91
|
+
userRole: {
|
|
92
|
+
personManager: 'Person Manager',
|
|
93
|
+
fineTemplateManager: 'Fine Template Manager',
|
|
94
|
+
fineManager: 'Fine Manager',
|
|
95
|
+
teamManager: 'Team Manager'
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { localizations } from './Localization';
|
|
2
|
+
import { Flattable, ITypeBuilder, keys, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
3
|
|
|
3
4
|
export class Configuration implements Flattable<Configuration.Flatten> {
|
|
4
5
|
|
|
@@ -26,11 +27,11 @@ export namespace Configuration {
|
|
|
26
27
|
export const builder = new ValueTypeBuilder<Currency>();
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export type Locale =
|
|
30
|
+
export type Locale = keyof typeof localizations;
|
|
30
31
|
|
|
31
32
|
export namespace Locale {
|
|
32
33
|
|
|
33
|
-
export const all: Locale[] =
|
|
34
|
+
export const all: Locale[] = keys(localizations);
|
|
34
35
|
|
|
35
36
|
export const builder = new ValueTypeBuilder<Locale>();
|
|
36
37
|
}
|
package/src/types/FineAmount.ts
CHANGED
|
@@ -56,11 +56,11 @@ export namespace FineAmount {
|
|
|
56
56
|
) {}
|
|
57
57
|
|
|
58
58
|
public formatted(): string {
|
|
59
|
-
return Localization.shared.
|
|
59
|
+
return Localization.shared.fineAmount.item.type[this.item].withCount.value(this.count);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
public formattedWithoutCount(): string {
|
|
63
|
-
return Localization.shared.
|
|
63
|
+
return Localization.shared.fineAmount.item.type[this.item].withoutCount.value(this.count);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
public multiplied(factor: number): Item {
|
|
@@ -86,7 +86,7 @@ export namespace FineAmount {
|
|
|
86
86
|
export const all: Type[] = ['crateOfBeer'];
|
|
87
87
|
|
|
88
88
|
export function formatted(type: Type): string {
|
|
89
|
-
return Localization.shared.
|
|
89
|
+
return Localization.shared.fineAmount.item.type[type].name.value();
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -9,11 +9,11 @@ export class FineTemplateRepetition implements Flattable<FineTemplateRepetition.
|
|
|
9
9
|
) {}
|
|
10
10
|
|
|
11
11
|
public formatted(count: number): string {
|
|
12
|
-
return Localization.shared.
|
|
12
|
+
return Localization.shared.fineTemplateRepetition.item[this.item].withCount.value(count);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
public formattedWithoutCount(count: number): string {
|
|
16
|
-
return Localization.shared.
|
|
16
|
+
return Localization.shared.fineTemplateRepetition.item[this.item].withoutCount.value(count);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
public get flatten(): FineTemplateRepetition.Flatten {
|
|
@@ -42,7 +42,7 @@ export namespace FineTemplateRepetition {
|
|
|
42
42
|
];
|
|
43
43
|
|
|
44
44
|
export function formatted(item: Item): string {
|
|
45
|
-
return Localization.shared.
|
|
45
|
+
return Localization.shared.fineTemplateRepetition.item[item].name.value();
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export const builder = new ValueTypeBuilder<Item>();
|
|
@@ -1,99 +1,83 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { keys, mapRecord, values } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
+
import { localizationEN } from '../locales/en';
|
|
3
|
+
import { localizationDE } from '../locales/de';
|
|
4
|
+
import { Pluralization } from './Pluralization';
|
|
3
5
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
title: 'notification.fine.new.title',
|
|
9
|
-
body: 'notification.fine.new.body'
|
|
10
|
-
},
|
|
11
|
-
reminder: {
|
|
12
|
-
title: 'notification.fine.reminder.title',
|
|
13
|
-
body: 'notification.fine.reminder.body'
|
|
14
|
-
},
|
|
15
|
-
stateChange: {
|
|
16
|
-
title: 'notification.fine.state-change.title',
|
|
17
|
-
bodyPayed: 'notification.fine.state-change.body-payed',
|
|
18
|
-
bodyUnpayed: 'notification.fine.state-change.body-unpayed',
|
|
19
|
-
bodyDeleted: 'notification.fine.state-change.body-deleted'
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
fineAmount: {
|
|
24
|
-
item: {
|
|
25
|
-
type: {
|
|
26
|
-
crateOfBeer: 'fineAmount.item.type.crateOfBeer'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
fineTemplateRepetition: {
|
|
31
|
-
item: {
|
|
32
|
-
minute: 'fineTemplateRepetition.item.minute',
|
|
33
|
-
day: 'fineTemplateRepetition.item.day',
|
|
34
|
-
item: 'fineTemplateRepetition.item.item',
|
|
35
|
-
count: 'fineTemplateRepetition.item.count'
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
payedState: {
|
|
39
|
-
payed: 'payedState.payed',
|
|
40
|
-
notPayed: 'payedState.notPayed'
|
|
41
|
-
},
|
|
42
|
-
userRole: {
|
|
43
|
-
personManager: 'userRole.personManager',
|
|
44
|
-
fineTemplateManager: 'userRole.fineTemplateManager',
|
|
45
|
-
fineManager: 'userRole.fineManager',
|
|
46
|
-
teamManager: 'userRole.teamManager'
|
|
47
|
-
}
|
|
48
|
-
}
|
|
6
|
+
export const localizations = {
|
|
7
|
+
en: localizationEN,
|
|
8
|
+
de: localizationDE
|
|
9
|
+
};
|
|
49
10
|
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
11
|
+
export type SubLocalizationType = { [Key in string]: SubLocalizationType } | string | Pluralization;
|
|
12
|
+
|
|
13
|
+
export type SubLocalization<T extends SubLocalizationType> =
|
|
14
|
+
T extends { [Key in string]: SubLocalizationType } ? { [Key in keyof T]: SubLocalization<T[Key]> } :
|
|
15
|
+
T extends string ? ValueLocalization :
|
|
16
|
+
T extends Pluralization ? PluralLocalization : never;
|
|
17
|
+
|
|
18
|
+
export class ValueLocalization {
|
|
19
|
+
|
|
20
|
+
constructor(private readonly rawValues: Record<keyof typeof localizations, string>) {}
|
|
21
|
+
|
|
22
|
+
public value(args: Record<string, string> = {}): string {
|
|
23
|
+
let rawValue = this.rawValues[Localization.locale];
|
|
24
|
+
const regex = /\{\{(?<key>.*?)\}\}/;
|
|
25
|
+
while (true) {
|
|
26
|
+
const match = regex.exec(rawValue);
|
|
27
|
+
if (!match)
|
|
28
|
+
break;
|
|
29
|
+
const key = match.groups!.key;
|
|
30
|
+
if (!(key in args))
|
|
31
|
+
throw new Error(`Missing argument for key: ${key}`);
|
|
32
|
+
rawValue = rawValue.replace(match[0], args[key]);
|
|
69
33
|
}
|
|
34
|
+
return rawValue;
|
|
70
35
|
}
|
|
71
36
|
}
|
|
72
37
|
|
|
73
|
-
export class
|
|
38
|
+
export class PluralLocalization {
|
|
74
39
|
|
|
75
|
-
|
|
40
|
+
constructor(private readonly pluralizations: Record<keyof typeof localizations, Pluralization>) {}
|
|
76
41
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
objectNotation: true
|
|
42
|
+
public value(count: number, args: Record<string, string> = {}): string {
|
|
43
|
+
const valueLocalization = new ValueLocalization(mapRecord(this.pluralizations, pluralization => pluralization.get(count)));
|
|
44
|
+
return valueLocalization.value({
|
|
45
|
+
count: `${count}`,
|
|
46
|
+
...args
|
|
83
47
|
});
|
|
84
48
|
}
|
|
49
|
+
}
|
|
85
50
|
|
|
86
|
-
|
|
87
|
-
|
|
51
|
+
function swap1stAnd2ndLevel<Level1Key extends string, Level2Key extends string, T>(record: Record<Level1Key, Record<Level2Key, T>>): Record<Level2Key, Record<Level1Key, T>> {
|
|
52
|
+
const swapped = {} as Record<Level2Key, Record<Level1Key, T>>;
|
|
53
|
+
for (const key1 of keys(record)) {
|
|
54
|
+
for (const key2 of keys(record[key1]) as Level2Key[]) {
|
|
55
|
+
if (!(key2 in swapped))
|
|
56
|
+
swapped[key2] = {} as Record<Level1Key, T>;
|
|
57
|
+
swapped[key2][key1] = record[key1][key2];
|
|
58
|
+
}
|
|
88
59
|
}
|
|
60
|
+
return swapped;
|
|
61
|
+
}
|
|
89
62
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
63
|
+
export class Localization {
|
|
64
|
+
|
|
65
|
+
public static locale: keyof typeof localizations = 'en';
|
|
94
66
|
|
|
95
|
-
public
|
|
96
|
-
|
|
97
|
-
|
|
67
|
+
public static readonly shared = Localization.getSubLocalization(localizations);
|
|
68
|
+
|
|
69
|
+
private static getSubLocalization<T extends SubLocalizationType>(_localizations: Record<keyof typeof localizations, T>): SubLocalization<T> {
|
|
70
|
+
const _localizationValue = values(_localizations);
|
|
71
|
+
if (_localizationValue.length === 0)
|
|
72
|
+
return {} as SubLocalization<T>;
|
|
73
|
+
if (typeof _localizationValue[0] === 'object' && !(_localizationValue[0] instanceof Pluralization)) {
|
|
74
|
+
const swapped = swap1stAnd2ndLevel(_localizations as Record<string, Record<string, SubLocalizationType>>);
|
|
75
|
+
return mapRecord(swapped, subLocalization => Localization.getSubLocalization(subLocalization)) as SubLocalization<T>;
|
|
76
|
+
}
|
|
77
|
+
if (typeof _localizationValue[0] === 'string')
|
|
78
|
+
return new ValueLocalization(_localizations as Record<keyof typeof localizations, string>) as SubLocalization<T>;
|
|
79
|
+
if (_localizationValue[0] instanceof Pluralization)
|
|
80
|
+
return new PluralLocalization(_localizations as Record<keyof typeof localizations, Pluralization>) as SubLocalization<T>;
|
|
81
|
+
throw new Error('Invalid localization structure');
|
|
98
82
|
}
|
|
99
83
|
}
|
package/src/types/PayedState.ts
CHANGED
|
@@ -10,7 +10,7 @@ export namespace PayedState {
|
|
|
10
10
|
export const all: PayedState[] = ['payed', 'notPayed'];
|
|
11
11
|
|
|
12
12
|
export function formatted(state: PayedState): string {
|
|
13
|
-
return Localization.shared.
|
|
13
|
+
return Localization.shared.payedState[state].value();
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function toggled(state: PayedState): PayedState {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export class Pluralization {
|
|
2
|
+
|
|
3
|
+
private readonly zero: string | null;
|
|
4
|
+
|
|
5
|
+
private readonly one: string | null;
|
|
6
|
+
|
|
7
|
+
private readonly two: string | null;
|
|
8
|
+
|
|
9
|
+
private readonly few: string | null;
|
|
10
|
+
|
|
11
|
+
private readonly many: string | null;
|
|
12
|
+
|
|
13
|
+
private readonly other: string;
|
|
14
|
+
|
|
15
|
+
public constructor(countLocals: {
|
|
16
|
+
zero?: string,
|
|
17
|
+
one?: string,
|
|
18
|
+
two?: string,
|
|
19
|
+
few?: string,
|
|
20
|
+
many?: string,
|
|
21
|
+
other: string
|
|
22
|
+
}) {
|
|
23
|
+
this.zero = countLocals.zero ?? null;
|
|
24
|
+
this.one = countLocals.one ?? null;
|
|
25
|
+
this.two = countLocals.two ?? null;
|
|
26
|
+
this.few = countLocals.few ?? null;
|
|
27
|
+
this.many = countLocals.many ?? null;
|
|
28
|
+
this.other = countLocals.other;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public get(count: number): string {
|
|
32
|
+
if (count === 0 && this.zero)
|
|
33
|
+
return this.zero;
|
|
34
|
+
else if (count === 1 && this.one)
|
|
35
|
+
return this.one;
|
|
36
|
+
else if (count === 2 && this.two)
|
|
37
|
+
return this.two;
|
|
38
|
+
else if (count > 1 && count < 5 && this.few)
|
|
39
|
+
return this.few;
|
|
40
|
+
else if (count >= 5 && count <= 20 && this.many)
|
|
41
|
+
return this.many;
|
|
42
|
+
return this.other;
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/types/UserRole.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
-
import { Localization,
|
|
2
|
+
import { Localization, localizations } from './Localization';
|
|
3
3
|
|
|
4
4
|
export type UserRole =
|
|
5
5
|
| 'person-manager'
|
|
@@ -17,13 +17,13 @@ export namespace UserRole {
|
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
export function formatted(role: UserRole): string {
|
|
20
|
-
const localizationKeyMap: Record<UserRole, keyof typeof
|
|
20
|
+
const localizationKeyMap: Record<UserRole, keyof (typeof localizations)[keyof typeof localizations]['userRole']> = {
|
|
21
21
|
'person-manager': 'personManager',
|
|
22
22
|
'fineTemplate-manager': 'fineTemplateManager',
|
|
23
23
|
'fine-manager': 'fineManager',
|
|
24
24
|
'team-manager': 'teamManager'
|
|
25
25
|
}
|
|
26
|
-
return Localization.shared.
|
|
26
|
+
return Localization.shared.userRole[localizationKeyMap[role]].value();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export const builder = new ValueTypeBuilder<UserRole>();
|
package/src/types/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './PayedState';
|
|
|
11
11
|
export * from './Person';
|
|
12
12
|
export * from './PersonPrivateProperties';
|
|
13
13
|
export * from './PersonSignInProperties';
|
|
14
|
+
export * from './Pluralization';
|
|
14
15
|
export * from './Team';
|
|
15
16
|
export * from './User';
|
|
16
17
|
export * from './UserRole';
|
package/lib/src/locales/de.json
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
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
|
-
"crateOfBeerWithoutCount?count=%s": {
|
|
29
|
-
"one": "Kasten Bier",
|
|
30
|
-
"other": "Kästen Bier"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"fineTemplateRepetition": {
|
|
36
|
-
"item": {
|
|
37
|
-
"minute": "Minute",
|
|
38
|
-
"minute?count=%s": {
|
|
39
|
-
"one": "1 Minute",
|
|
40
|
-
"other": "%s Minuten"
|
|
41
|
-
},
|
|
42
|
-
"minuteWithoutCount?count=%s": {
|
|
43
|
-
"one": "Minute",
|
|
44
|
-
"other": "Minuten"
|
|
45
|
-
},
|
|
46
|
-
"day": "Tag",
|
|
47
|
-
"day?count=%s": {
|
|
48
|
-
"one": "1 Tag",
|
|
49
|
-
"other": "%s Tage"
|
|
50
|
-
},
|
|
51
|
-
"dayWithoutCount?count=%s": {
|
|
52
|
-
"one": "Tag",
|
|
53
|
-
"other": "Tage"
|
|
54
|
-
},
|
|
55
|
-
"item": "Teil",
|
|
56
|
-
"item?count=%s": {
|
|
57
|
-
"one": "1 Teil",
|
|
58
|
-
"other": "%s Teile"
|
|
59
|
-
},
|
|
60
|
-
"itemWithoutCount?count=%s": {
|
|
61
|
-
"one": "Teil",
|
|
62
|
-
"other": "Teile"
|
|
63
|
-
},
|
|
64
|
-
"count": "Anzahl",
|
|
65
|
-
"count?count=%s": {
|
|
66
|
-
"one": "1 mal",
|
|
67
|
-
"other": "%s mal"
|
|
68
|
-
},
|
|
69
|
-
"countWithoutCount?count=%s": {
|
|
70
|
-
"one": "mal",
|
|
71
|
-
"other": "mal"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"payedState": {
|
|
76
|
-
"payed": "Bezahlt",
|
|
77
|
-
"notPayed": "Offen"
|
|
78
|
-
},
|
|
79
|
-
"userRole": {
|
|
80
|
-
"personManager": "Personenmanager",
|
|
81
|
-
"fineTemplateManager": "Strafvorlagenmanager",
|
|
82
|
-
"fineManager": "Strafenmanager",
|
|
83
|
-
"teamManager": "Teammanager"
|
|
84
|
-
}
|
|
85
|
-
}
|