@dizmo/dcs-client-library 4.2.2 → 4.2.3

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.
@@ -6,6 +6,7 @@
6
6
  import { language } from "../modules/language";
7
7
  import { HumanizeDurationLanguage, HumanizeDuration, } from "humanize-duration-ts";
8
8
  import { AllocationMode } from "../types/types";
9
+ import { t } from "./componentTranslations";
9
10
  import "./itemElement";
10
11
  class AllocationElement extends HTMLElement {
11
12
  constructor() {
@@ -78,11 +79,11 @@ class AllocationElement extends HTMLElement {
78
79
  : "";
79
80
  const infoRows = this.buildInfoRows([
80
81
  {
81
- label: language.translateString("js_from"),
82
+ label: t("js_from"),
82
83
  value: from ? getReadableTime(parseInt(from)) : "",
83
84
  },
84
85
  {
85
- label: language.translateString("js_to"),
86
+ label: t("js_to"),
86
87
  value: to ? getReadableTime(parseInt(to)) : "",
87
88
  },
88
89
  ]);
@@ -127,13 +128,13 @@ class AllocationElement extends HTMLElement {
127
128
  const duration = this.getAttribute("duration");
128
129
  const infoRows = this.buildInfoRows([
129
130
  {
130
- label: language.translateString("js_start"),
131
+ label: t("js_start"),
131
132
  value: item.template
132
133
  ? formatStartOffset(startOffset, humanizer, LANG)
133
134
  : "",
134
135
  },
135
136
  {
136
- label: language.translateString("js_duration"),
137
+ label: t("js_duration"),
137
138
  value: item.template ? formatDuration(duration, humanizer, LANG) : "",
138
139
  },
139
140
  ]);
@@ -172,6 +173,7 @@ class AllocationElement extends HTMLElement {
172
173
  .info-row {
173
174
  display: flex;
174
175
  flex-direction: row;
176
+ justify-content: space-between;
175
177
  }
176
178
  .info-label {
177
179
  width: 80px;
@@ -195,7 +197,7 @@ const formatStartOffset = (startOffset, humanizer, lang) => {
195
197
  return "";
196
198
  const offset = parseInt(startOffset);
197
199
  if (offset === 0) {
198
- return language.translateString("js_at-start");
200
+ return t("js_at-start");
199
201
  }
200
202
  return ("+" +
201
203
  humanizer.humanize(offset, {
@@ -0,0 +1 @@
1
+ export declare function t(key: string): string;
@@ -0,0 +1,48 @@
1
+ import { getMostSuitedLanguage } from "../helper/language.js";
2
+ const translations = {
3
+ en: {
4
+ js_from: "From",
5
+ js_to: "To",
6
+ js_start: "Start",
7
+ js_duration: "Duration",
8
+ "js_at-start": "At start",
9
+ need_suffix: "Need",
10
+ },
11
+ de: {
12
+ js_from: "Von",
13
+ js_to: "Bis",
14
+ js_start: "Start",
15
+ js_duration: "Dauer",
16
+ "js_at-start": "Am Anfang",
17
+ need_suffix: "Bedarf",
18
+ },
19
+ fr: {
20
+ js_from: "De",
21
+ js_to: "À",
22
+ js_start: "Début",
23
+ js_duration: "Durée",
24
+ "js_at-start": "Au début",
25
+ need_suffix: "Besoin",
26
+ },
27
+ it: {
28
+ js_from: "Da",
29
+ js_to: "A",
30
+ js_start: "Inizio",
31
+ js_duration: "Durata",
32
+ "js_at-start": "All'inizio",
33
+ need_suffix: "Fabbisogno",
34
+ },
35
+ es: {
36
+ js_from: "De",
37
+ js_to: "A",
38
+ js_start: "Inicio",
39
+ js_duration: "Duración",
40
+ "js_at-start": "Al inicio",
41
+ need_suffix: "Necesidad",
42
+ },
43
+ };
44
+ const supportedLanguages = Object.keys(translations);
45
+ export function t(key) {
46
+ const lang = getMostSuitedLanguage(supportedLanguages, "en");
47
+ return translations[lang]?.[key] ?? translations["en"][key] ?? key;
48
+ }
@@ -1,5 +1,6 @@
1
1
  // Shared web component that can display resource, package, need, and event items.
2
2
  import { ItemType } from "../types/types";
3
+ import { t } from "./componentTranslations";
3
4
  const packageIconLight = `data:image/svg+xml,${encodeURIComponent('<svg width="27.5" height="27.5" xmlns="http://www.w3.org/2000/svg" xml:space="preserve"><path d="m4.42,22.06l0,-6.22l3.11,0l0,6.22l-3.11,0zm5.18,-6.22l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,-5.18l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,11.41l0,-16.59l3.11,0l0,16.59l-3.11,0z" fill="#424142" transform="rotate(-90.2178 13.7484 13.7683)"/></svg>')}`;
4
5
  const packageIconDark = `data:image/svg+xml,${encodeURIComponent('<svg width="27.5" height="27.5" xmlns="http://www.w3.org/2000/svg" xml:space="preserve"><path d="m4.42,22.06l0,-6.22l3.11,0l0,6.22l-3.11,0zm5.18,-6.22l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,-5.18l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,11.41l0,-16.59l3.11,0l0,16.59l-3.11,0z" fill="#ffffff" transform="rotate(-90.2178 13.7484 13.7683)"/></svg>')}`;
5
6
  const needBadgeIcon = `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M477.28-240q21.96 0 37.3-15.34 15.33-15.33 15.33-37.32 0-21.99-15.33-37.18-15.34-15.18-37.3-15.18-21.95 0-37.29 15.18-15.34 15.19-15.34 37.18 0 21.99 15.34 37.32Q455.33-240 477.28-240ZM483.28-646.98q23.07 0 40.15 14.91 17.07 14.91 17.07 37.27 0 20.8-12.66 37.08-12.67 16.29-28.71 30.33-23 20-40.62 44.24-17.62 24.24-17.62 54.24 0 14.81 11.15 24.86Q463.2-394 478.07-394q15.93 0 27.15-10.6 11.21-10.6 15.17-26.31 4.48-20.05 17.64-35.71 13.17-15.66 28.45-29.95 23-21.76 39.02-48.11 16.02-26.36 16.02-58.12 0-51.48-41.14-84.58t-95.9-33.1q-38.96 0-73.82 16.48-34.86 16.48-53.81 49.96-7.48 12.71-4.76 27.16 2.73 14.45 14.71 21.95 14.72 8.71 30.8 5.35 16.07-3.35 27.03-17.83 10.52-14.05 26.09-21.81 15.58-7.76 32.56-7.76Z"/></svg>')}`;
@@ -39,7 +40,7 @@ class ItemElement extends HTMLElement {
39
40
  const showLeftImage = itemType === ItemType.Resource && (imgUrl || iconUrl);
40
41
  // Resources and needs show secondline, events show formatted date
41
42
  const displaySecondLine = itemType === ItemType.Need && secondline
42
- ? `${secondline} Need`
43
+ ? `${secondline} ${t("need_suffix")}`
43
44
  : secondline;
44
45
  const showSecondLine = (itemType === ItemType.Resource || itemType === ItemType.Need) &&
45
46
  displaySecondLine;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dizmo/dcs-client-library",
3
- "version": "4.2.2",
3
+ "version": "4.2.3",
4
4
  "description": "A library that allows connection and management of dcs",
5
5
  "source": "source/index.ts",
6
6
  "main": "dist/index.js",