Skip to content

Commit

Permalink
add translations and types for units and physical dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
flxdot committed May 1, 2024
1 parent 69a9238 commit ea182d0
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
23 changes: 22 additions & 1 deletion services/frontend/src/api/unit-of-measurement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export enum EUnitOfMeasurement {
}

/*
* Ensures that each available UnitOfMeasurement is present in the EUnitOfMeasurement
* This map exists to formally couple the EUnitOfMeasurement and the UnitOfMeasurement
* from the API.
*/
export const UnitOfMeasurementMap: Record<components['schemas']['UnitOfMeasurement'], keyof typeof EUnitOfMeasurement> = {
0: 'UNIT_LESS',
Expand All @@ -31,3 +32,23 @@ export const UnitOfMeasurementSymbol: Record<EUnitOfMeasurement, string> = {
[EUnitOfMeasurement.HUMIDITY_PERCENTAGE]: '%',
[EUnitOfMeasurement.LUX]: 'lx',
};

export enum EPhysicalDimension {
IDENTITY= 0,
TEMPERATURE =1,
HUMIDITY = 2,
ILLUMINANCE = 3,
RATIO = 4,
}

/*
* This map exists to formally couple the EPhysicalDimension and the PhysicalQuantity
* from the API.
*/
export const PhysicalQuantityMap: Record<components['schemas']['PhysicalQuantity'], keyof typeof EPhysicalDimension> = {
0: 'IDENTITY',
1: 'TEMPERATURE',
2: 'HUMIDITY',
3: 'ILLUMINANCE',
4: 'RATIO',
};
20 changes: 20 additions & 0 deletions services/frontend/src/plugins/i18n/translations/de.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ERouteName,
} from '@/router/route-name.ts';
import {EPhysicalDimension, EUnitOfMeasurement} from "@/api/unit-of-measurement.ts";

Check failure on line 4 in services/frontend/src/plugins/i18n/translations/de.ts

View workflow job for this annotation

GitHub Actions / test

Expected a line break after this opening brace

Check failure on line 4 in services/frontend/src/plugins/i18n/translations/de.ts

View workflow job for this annotation

GitHub Actions / test

A space is required after '{'

Check failure on line 4 in services/frontend/src/plugins/i18n/translations/de.ts

View workflow job for this annotation

GitHub Actions / test

Expected a line break before this closing brace

Check failure on line 4 in services/frontend/src/plugins/i18n/translations/de.ts

View workflow job for this annotation

GitHub Actions / test

A space is required before '}'

Check failure on line 4 in services/frontend/src/plugins/i18n/translations/de.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

const authentication = {
login: 'Anmelden',
Expand Down Expand Up @@ -48,6 +49,23 @@ const pages = {
[ERouteName.DEVICES_OVERVIEW]: 'Geräte Übersicht',
};

const unitOfMeasurement: Record<EUnitOfMeasurement, string> = {
[EUnitOfMeasurement.UNIT_LESS]: '',
[EUnitOfMeasurement.PERCENTAGE]: 'Prozent',
[EUnitOfMeasurement.CELSIUS]: 'Grad Celsius',
[EUnitOfMeasurement.FAHRENHEIT]: 'Grad Fahrenheit',
[EUnitOfMeasurement.HUMIDITY_PERCENTAGE]: 'Prozent',
[EUnitOfMeasurement.LUX]: 'Lux',
};

const physicalDimension: Record<EPhysicalDimension, string> = {
[EPhysicalDimension.IDENTITY]: 'Einheit',
[EPhysicalDimension.TEMPERATURE]: 'Temperatur',
[EPhysicalDimension.HUMIDITY]: 'Feuchtigkeit',
[EPhysicalDimension.ILLUMINANCE]: 'Helligkeit',
[EPhysicalDimension.RATIO]: 'Verhältnis',
};

export default {
authentication,
chart,
Expand All @@ -56,4 +74,6 @@ export default {
error,
navbar,
pages,
unitOfMeasurement,
physicalDimension,
};
20 changes: 20 additions & 0 deletions services/frontend/src/plugins/i18n/translations/en.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ERouteName,
} from '@/router/route-name.ts';
import {EPhysicalDimension, EUnitOfMeasurement} from "@/api/unit-of-measurement.ts";

Check failure on line 4 in services/frontend/src/plugins/i18n/translations/en.ts

View workflow job for this annotation

GitHub Actions / test

Expected a line break after this opening brace

Check failure on line 4 in services/frontend/src/plugins/i18n/translations/en.ts

View workflow job for this annotation

GitHub Actions / test

A space is required after '{'

Check failure on line 4 in services/frontend/src/plugins/i18n/translations/en.ts

View workflow job for this annotation

GitHub Actions / test

Expected a line break before this closing brace

Check failure on line 4 in services/frontend/src/plugins/i18n/translations/en.ts

View workflow job for this annotation

GitHub Actions / test

A space is required before '}'

const authentication = {
login: 'Login',
Expand Down Expand Up @@ -48,6 +49,23 @@ const pages = {
[ERouteName.DEVICES_OVERVIEW]: 'Devices Overview',
};

const unitOfMeasurement: Record<EUnitOfMeasurement, string> = {
[EUnitOfMeasurement.UNIT_LESS]: '',
[EUnitOfMeasurement.PERCENTAGE]: 'Percent',
[EUnitOfMeasurement.CELSIUS]: 'Degrees Celsius',
[EUnitOfMeasurement.FAHRENHEIT]: 'Degrees Fahrenheit',
[EUnitOfMeasurement.HUMIDITY_PERCENTAGE]: 'Percent',
[EUnitOfMeasurement.LUX]: 'Lux',
};

const physicalDimension: Record<EPhysicalDimension, string> = {
[EPhysicalDimension.IDENTITY]: 'Identity',
[EPhysicalDimension.TEMPERATURE]: 'Temperature',
[EPhysicalDimension.HUMIDITY]: 'Humidity',
[EPhysicalDimension.ILLUMINANCE]: 'Illuminance',
[EPhysicalDimension.RATIO]: 'Ratio',
};

export default {
authentication,
chart,
Expand All @@ -56,4 +74,6 @@ export default {
error,
navbar,
pages,
unitOfMeasurement,
physicalDimension,
};

0 comments on commit ea182d0

Please sign in to comment.