Skip to content

Commit

Permalink
Internationalize some frontend components
Browse files Browse the repository at this point in the history
  • Loading branch information
cdauth committed Apr 3, 2024
1 parent 09ebec0 commit 99673bd
Show file tree
Hide file tree
Showing 5 changed files with 317 additions and 54 deletions.
61 changes: 61 additions & 0 deletions frontend/src/i18n/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,67 @@ const messagesDe = {
"icons": `Symbole`
},

"click-marker-tab": {
"look-up-error": `Fehler beim Laden der Geoinformationen`
},

"client-provider": {
"loading-map-header": `Karte wird geladen`,
"loading-map": `Karte wird geladen…`,
"connecting-header": `Verbindung wird hergestellt`,
"connecting": `Verbindung mit dem Server wird hergestellt…`,
"map-deleted-header": `Karte gelöscht`,
"map-deleted": `Die Karte wurde gelöscht.`,
"close-map": `Karte schließen`,
"connection-error": `Bei der Verbindung zum Server ist ein Fehler aufgetreten`,
"open-map-error": `Beim Öffnen der Karte ist ein Fehler aufgetreten`,
"disconnected-header": `Verbindung unterbrochen`,
"disconnected": `Die Verbindung zum Server ist verloren gegangen. Verbindung wird wiederhergestellt…`
},

"edit-filter-dialog": {
"title": `Filter`,
"apply": `Anwenden`,
"introduction": `Hier können Sie eine Filterformel festlegen, die definiert, welche Marker/Linien basierend auf ihren Attributen angezeigt/versteckt werden sollen. Die Filterformel beeinflusst nur Ihre persönliche Ansicht der Karte, sie kann jedoch als Teil einer gespeicherten Ansicht oder eines geteilten Links wiederverwendet werden.`,
"syntax-header": `Syntax`,
"variable": `Variable`,
"operator": `Operator`,
"description": `Beschreibung`,
"example": `Beispiel`,
"name-description": `Name des Markers oder der Linie`,
"type-description": `Art des Objekts: {{marker}} (Marker) / {{line}} (Linie)`,
"typeId-description": `Typ des Objekts: {{items}})`,
"typeId-description-item": `{{typeId}} ({{typeName}})`,
"typeId-description-separator": ` / `,
"data-description-1": `Feldwerte (Beispiel: {{example1}} oder {{example2}}).`,
"data-description-2": `Für Checkbox-Felder ist der Wert {{uncheckedValue}} (nicht selektiert) oder {{checkedValue}} (selektiert).`,
"lon-lat-description": `Koordinaten des Markers`,
"colour-description": `Farbe des Markers oder der Linie`,
"size-description": `Größe des Markers`,
"symbol-description": `Symbol des Markers`,
"shape-description": `Form des Markers`,
"ele-description": `Höhe über NN des Markers`,
"mode-description": `Routenmethode der Linie (z.\u202fB. {{straight}} (Luftlinie) / {{car}} (Auto) / {{bicycle}} (Fahrrad) / {{pedestrian}} (zu Fuß) / {{track}} (importierter GPX-Track))`,
"width-description": `Dicke der Linie`,
"stroke-description": `Kontur der Linie ({{solid}} (durchgezogen) / {{dashed}} (gestrichelt) / {{dotted}} (gepunktet))`,
"distance-description": `Länge der Linie in Kilometern`,
"time-description": `Reisedauer der Linie in Sekunden`,
"ascent-descent-description": `Gesamteranstieg/-abstieg der Linie`,
"routePoints-description": `Koordinaten der Wegpunkte der Linie`,
"number-description": `Zahl`,
"text-description": `Zeichenkette`,
"mathematical-description": `Mathematische Operationen ({{modulo}}: modulo, {{power}}: Potenz)`,
"logical-description": `Logische Operationen`,
"ternary-description": `Wenn/dann/sonst-Operator`,
"comparison-description": `Vergleich ({{notEqual}}: ungleich) (Groß-/Kleinschreibung relevant)`,
"list-description": `Listen-Operator ({{in}}: Wert kommt in der Liste vor, {{notIn}}: Wert kommt nicht in der Liste vor) (Groß-/Kleinschreibung relevant)`,
"regexp-description": `Regulärer Ausdruck (Groß-/Kleinschreibung relevant)`,
"lower-description": `Zu Kleinbuchstaben konvertieren`,
"round-description": `Runden ({{round}}: kaufmännisch runden, {{ceil}}: aufrunden, {{floor}}: abrunden)`,
"functions-description": `Mathematische Funktionen ({{abs}}: Betrag, {{log}}: Natürlicher Logarithmus, {{sqrt}}: Quadratwurzel)`,
"min-max-description": `Kleinster/größter Wert`
},

"modal-dialog": {
"close": "Schließen",
"cancel": "Abbrechen",
Expand Down
61 changes: 61 additions & 0 deletions frontend/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,67 @@ const messagesEn = {
"icons": `Icons`
},

"click-marker-tab": {
"look-up-error": `Error looking up point`
},

"client-provider": {
"loading-map-header": `Loading`,
"loading-map": `Loading map…`,
"connecting-header": `Connecting`,
"connecting": `Connecting to server…`,
"map-deleted-header": `Map deleted`,
"map-deleted": `This map has been deleted.`,
"close-map": `Close map`,
"connection-error": `Error connecting to server`,
"open-map-error": `Error opening map`,
"disconnected-header": `Disconnected`,
"disconnected": `The connection to the server was lost. Trying to reconnect…`
},

"edit-filter-dialog": {
"title": `Filter`,
"apply": `Apply`,
"introduction": `Here you can set an advanced expression to show/hide certain markers/lines based on their attributes. The filter expression only applies to your view of the map, but it can be persisted as part of a saved view or a shared link.`,
"syntax-header": `Syntax`,
"variable": `Variable`,
"operator": `Operator`,
"description": `Description`,
"example": `Example`,
"name-description": `Marker/Line name`,
"type-description": `{{marker}} / {{line}}`,
"typeId-description": `{{items}})`,
"typeId-description-item": `{{typeId}} ({{typeName}})`,
"typeId-description-separator": ` / `,
"data-description-1": `Field values (example: {{example1}} or {{example2}}).`,
"data-description-2": `For checkbox fields, the value is {{uncheckedValue}} (unchecked) or {{checkedValue}} (checked).`,
"lon-lat-description": `Marker coordinates`,
"colour-description": `Marker/line colour`,
"size-description": `Marker size`,
"symbol-description": `Marker icon`,
"shape-description": `Marker shape`,
"ele-description": `Marker elevation`,
"mode-description": `Line routing mode ({{straight}} / {{car}} / {{bicycle}} / {{pedestrian}} / {{track}})`,
"width-description": `Line width`,
"stroke-description": `Line stroke ({{solid}} (solid) / {{dashed}} / {{dotted}})`,
"distance-description": `Line distance in kilometers`,
"time-description": `Line routing time in seconds`,
"ascent-descent-description": `Total ascent/descent of line`,
"routePoints-description": `Line point coordinates`,
"number-description": `Numerical value`,
"text-description": `Text value`,
"mathematical-description": `Mathematical operations ({{modulo}}: modulo, {{power}}: power)`,
"logical-description": `Logical operators`,
"ternary-description": `if/then/else operator`,
"comparison-description": `Comparison ({{notEqual}}: not equal) (case sensitive)`,
"list-description": `List operator (case sensitive)`,
"regexp-description": `Regular expression match (case sensitive)`,
"lower-description": `Convert to lower case`,
"round-description": `Round ({{ceil}}: up, {{floor}}: down)`,
"functions-description": `Mathematical functions`,
"min-max-description": `Smallest/highest value`
},

"modal-dialog": {
"close": "Close",
"cancel": "Cancel",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/lib/components/click-marker-tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import { injectContextRequired, requireMapContext, requireSearchBoxContext } from "./facil-map-context-provider/facil-map-context-provider.vue";
import type { WritableClickMarkerTabContext } from "./facil-map-context-provider/click-marker-tab-context";
import { useToasts } from "./ui/toasts/toasts.vue";
import { useI18n } from "../utils/i18n";
const toasts = useToasts();
const i18n = useI18n();
const context = injectContextRequired();
const mapContext = requireMapContext(context);
Expand Down Expand Up @@ -69,7 +71,7 @@
tab.isLoading = false;
})().catch((err) => {
toasts.showErrorToast(`find-error-${tab.id}`, "Error looking up point", err);
toasts.showErrorToast(`find-error-${tab.id}`, i18n.t("click-marker-tab.look-up-error"), err);
});
(async () => {
Expand Down
20 changes: 11 additions & 9 deletions frontend/src/lib/components/client-provider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Toast from "./ui/toasts/toast.vue";
import type { ClientContext } from "./facil-map-context-provider/client-context";
import { injectContextRequired } from "./facil-map-context-provider/facil-map-context-provider.vue";
import { useI18n } from "../utils/i18n";
function isPadNotFoundError(serverError: Client["serverError"]): boolean {
return !!serverError && serverError instanceof PadNotFoundError;
Expand All @@ -17,6 +18,7 @@
<script setup lang="ts">
const context = injectContextRequired();
const toasts = useToasts();
const i18n = useI18n();
const client = ref<ClientContext>();
const connectingClient = ref<ClientContext>();
Expand Down Expand Up @@ -46,9 +48,9 @@
toasts.hideToast(`fm${context.id}-client-error`);
toasts.hideToast(`fm${context.id}-client-deleted`);
if (props.padId)
toasts.showToast(`fm${context.id}-client-connecting`, "Loading", "Loading map", { spinner: true, noCloseButton: true });
toasts.showToast(`fm${context.id}-client-connecting`, i18n.t("client-provider.loading-map-header"), i18n.t("client-provider.loading-map"), { spinner: true, noCloseButton: true });
else
toasts.showToast(`fm${context.id}-client-connecting`, "Connecting", "Connecting to server…", { spinner: true, noCloseButton: true });
toasts.showToast(`fm${context.id}-client-connecting`, i18n.t("client-provider.connecting-header"), i18n.t("client-provider.connecting"), { spinner: true, noCloseButton: true });
class CustomClient extends Client implements ClientContext {
_makeReactive<O extends object>(obj: O) {
Expand Down Expand Up @@ -87,12 +89,12 @@
});
newClient.on("deletePad", () => {
toasts.showToast(`fm${context.id}-client-deleted`, "Map deleted", "This map has been deleted.", {
toasts.showToast(`fm${context.id}-client-deleted`, i18n.t("client-provider.map-deleted-header"), i18n.t("client-provider.map-deleted"), {
noCloseButton: true,
variant: "danger",
actions: context.settings.interactive ? [
{
label: "Close map",
label: i18n.t("client-provider.close-map"),
href: context.baseUrl,
onClick: (e) => {
if (!e.ctrlKey && !e.shiftKey && !e.metaKey && !e.altKey) {
Expand Down Expand Up @@ -127,15 +129,15 @@
if (newClient.serverError && !newClient.isCreatePad) {
if (newClient.disconnected || !props.padId) {
toasts.showErrorToast(`fm${context.id}-client-error`, "Error connecting to server", newClient.serverError, {
toasts.showErrorToast(`fm${context.id}-client-error`, i18n.t("client-provider.connection-error"), newClient.serverError, {
noCloseButton: !!props.padId
});
} else {
toasts.showErrorToast(`fm${context.id}-client-error`, "Error opening map", newClient.serverError, {
toasts.showErrorToast(`fm${context.id}-client-error`, i18n.t("client-provider.open-map-error"), newClient.serverError, {
noCloseButton: true,
actions: context.settings.interactive ? [
{
label: "Close map",
label: i18n.t("client-provider.close-map"),
href: context.baseUrl,
onClick: (e) => {
if (!e.ctrlKey && !e.shiftKey && !e.metaKey && !e.altKey) {
Expand Down Expand Up @@ -172,8 +174,8 @@
v-if="client && client.disconnected && !client.serverError"
:id="`fm${context.id}-client-disconnected`"
variant="danger"
title="Disconnected"
message="The connection to the server was lost. Trying to reconnect…"
:title="i18n.t('client-provider.disconnected-header')"
:message="i18n.t('client-provider.disconnected')"
auto-hide
no-close-button visible
spinner
Expand Down
Loading

0 comments on commit 99673bd

Please sign in to comment.