From 92c05144b98bf6b056b01be1efd7e26d56266f20 Mon Sep 17 00:00:00 2001 From: Christian Beutel <> Date: Fri, 10 Jan 2025 17:23:12 +0100 Subject: [PATCH] adds spanish language options --- db/migrations/1736525966_updated_settings.go | 91 +++++++++++++++++++ web/src/lib/i18n/locales/de.json | 1 + web/src/lib/i18n/locales/en.json | 1 + web/src/lib/i18n/locales/es.json | 1 + web/src/lib/i18n/locales/fr.json | 3 +- web/src/lib/i18n/locales/hu.json | 1 + web/src/lib/i18n/locales/it.json | 1 + web/src/lib/i18n/locales/nl.json | 1 + web/src/lib/i18n/locales/pl.json | 1 + web/src/lib/i18n/locales/pt.json | 1 + web/src/lib/i18n/locales/zh.json | 1 + web/src/lib/models/api/settings_schema.ts | 2 +- web/src/lib/models/settings.ts | 4 +- web/src/routes/settings/language/+page.svelte | 3 +- 14 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 db/migrations/1736525966_updated_settings.go diff --git a/db/migrations/1736525966_updated_settings.go b/db/migrations/1736525966_updated_settings.go new file mode 100644 index 00000000..a0a20701 --- /dev/null +++ b/db/migrations/1736525966_updated_settings.go @@ -0,0 +1,91 @@ +package migrations + +import ( + "encoding/json" + + "github.com/pocketbase/dbx" + "github.com/pocketbase/pocketbase/daos" + m "github.com/pocketbase/pocketbase/migrations" + "github.com/pocketbase/pocketbase/models/schema" +) + +func init() { + m.Register(func(db dbx.Builder) error { + dao := daos.New(db); + + collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13") + if err != nil { + return err + } + + // update + edit_language := &schema.SchemaField{} + if err := json.Unmarshal([]byte(`{ + "system": false, + "id": "0sepzvkh", + "name": "language", + "type": "select", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "en", + "de", + "fr", + "hu", + "it", + "nl", + "pl", + "pt", + "zh", + "es" + ] + } + }`), edit_language); err != nil { + return err + } + collection.Schema.AddField(edit_language) + + return dao.SaveCollection(collection) + }, func(db dbx.Builder) error { + dao := daos.New(db); + + collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13") + if err != nil { + return err + } + + // update + edit_language := &schema.SchemaField{} + if err := json.Unmarshal([]byte(`{ + "system": false, + "id": "0sepzvkh", + "name": "language", + "type": "select", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "en", + "de", + "fr", + "hu", + "it", + "nl", + "pl", + "pt", + "zh" + ] + } + }`), edit_language); err != nil { + return err + } + collection.Schema.AddField(edit_language) + + return dao.SaveCollection(collection) + }) +} diff --git a/web/src/lib/i18n/locales/de.json b/web/src/lib/i18n/locales/de.json index 3a42b87e..c308fb3f 100644 --- a/web/src/lib/i18n/locales/de.json +++ b/web/src/lib/i18n/locales/de.json @@ -255,6 +255,7 @@ "slope": "Steigung", "someone": "Jemand", "sort": "Sortieren", + "spanish": "Spanisch", "speed": "Geschwindigkeit", "statistics": "Statistiken", "stop-drawing": "Zeichnen beenden", diff --git a/web/src/lib/i18n/locales/en.json b/web/src/lib/i18n/locales/en.json index 93e0c73a..e245d22a 100644 --- a/web/src/lib/i18n/locales/en.json +++ b/web/src/lib/i18n/locales/en.json @@ -255,6 +255,7 @@ "slope": "Slope", "someone": "Someone", "sort": "Sort", + "spanish": "Spanish", "speed": "Speed", "statistics": "Statistics", "stop-drawing": "Stop drawing", diff --git a/web/src/lib/i18n/locales/es.json b/web/src/lib/i18n/locales/es.json index 76d519e2..74c7df75 100644 --- a/web/src/lib/i18n/locales/es.json +++ b/web/src/lib/i18n/locales/es.json @@ -255,6 +255,7 @@ "slope": "Pendiente", "someone": "Alguien", "sort": "Ordenar", + "spanish": "Español", "speed": "Velocidad", "statistics": "Estadísticas", "stop-drawing": "Parar de diseñar", diff --git a/web/src/lib/i18n/locales/fr.json b/web/src/lib/i18n/locales/fr.json index f40c94d9..74da3927 100644 --- a/web/src/lib/i18n/locales/fr.json +++ b/web/src/lib/i18n/locales/fr.json @@ -146,7 +146,7 @@ "list-not-shared": "Not shared with anyone", "list-public-warning": "Tous les itinéraires de cette liste seront publics.", "list-saved-successfully": "Liste enregistrée avec succès", - "list-share-warning": "", + "list-share-warning": "Le partage d'une liste partage automatiquement toutes les pistes qu'elle contient.", "list-share-warning-update": "Added trails will be shared with everyone that has access to this list.", "location": "Localisation", "login": "Connexion", @@ -255,6 +255,7 @@ "slope": "Pente", "someone": "Someone", "sort": "Trier", + "spanish": "Espagnol", "speed": "Vitesse", "statistics": "Statistics", "stop-drawing": "Arrêter de tracer", diff --git a/web/src/lib/i18n/locales/hu.json b/web/src/lib/i18n/locales/hu.json index aeab3ed5..f2bcc1ac 100644 --- a/web/src/lib/i18n/locales/hu.json +++ b/web/src/lib/i18n/locales/hu.json @@ -255,6 +255,7 @@ "slope": "Slope", "someone": "Someone", "sort": "Rendezés", + "spanish": "spanyol", "speed": "Speed", "statistics": "Statistics", "stop-drawing": "Stop drawing", diff --git a/web/src/lib/i18n/locales/it.json b/web/src/lib/i18n/locales/it.json index 6c4b0e8e..2a43652b 100644 --- a/web/src/lib/i18n/locales/it.json +++ b/web/src/lib/i18n/locales/it.json @@ -255,6 +255,7 @@ "slope": "Pendenza", "someone": "Someone", "sort": "Ordina", + "spanish": "spagnolo", "speed": "Velocità", "statistics": "Statistics", "stop-drawing": "Smettere di disegnare", diff --git a/web/src/lib/i18n/locales/nl.json b/web/src/lib/i18n/locales/nl.json index c6903bc6..e506db9e 100644 --- a/web/src/lib/i18n/locales/nl.json +++ b/web/src/lib/i18n/locales/nl.json @@ -255,6 +255,7 @@ "slope": "Slope", "someone": "Someone", "sort": "Sorteren", + "spanish": "Spaans", "speed": "Speed", "statistics": "Statistics", "stop-drawing": "Stop drawing", diff --git a/web/src/lib/i18n/locales/pl.json b/web/src/lib/i18n/locales/pl.json index 8cf24b6d..9bc6d862 100644 --- a/web/src/lib/i18n/locales/pl.json +++ b/web/src/lib/i18n/locales/pl.json @@ -255,6 +255,7 @@ "slope": "Nachylenie", "someone": "Someone", "sort": "Sortowanie", + "spanish": "hiszpański", "speed": "Prędkość", "statistics": "Statistics", "stop-drawing": "Przestań rysować", diff --git a/web/src/lib/i18n/locales/pt.json b/web/src/lib/i18n/locales/pt.json index 6f0f96b3..adba37cb 100644 --- a/web/src/lib/i18n/locales/pt.json +++ b/web/src/lib/i18n/locales/pt.json @@ -255,6 +255,7 @@ "slope": "Inclinação", "someone": "Someone", "sort": "Ordenar", + "spanish": "Espanhol", "speed": "Velocidade", "statistics": "Statistics", "stop-drawing": "Parar desenho", diff --git a/web/src/lib/i18n/locales/zh.json b/web/src/lib/i18n/locales/zh.json index f21ef9f5..30ad7d7b 100644 --- a/web/src/lib/i18n/locales/zh.json +++ b/web/src/lib/i18n/locales/zh.json @@ -255,6 +255,7 @@ "slope": "坡度", "someone": "Someone", "sort": "排序", + "spanish": "西班牙语", "speed": "速度", "statistics": "Statistics", "stop-drawing": "停止绘制", diff --git a/web/src/lib/models/api/settings_schema.ts b/web/src/lib/models/api/settings_schema.ts index 0a826365..98591ec9 100644 --- a/web/src/lib/models/api/settings_schema.ts +++ b/web/src/lib/models/api/settings_schema.ts @@ -4,7 +4,7 @@ import type { Settings } from "../settings"; const SettingsCreateSchema = z.object({ unit: z.enum(["metric", "imperial"]).optional(), - language: z.enum(["en", "de", "fr", "hu", "it", "nl", "pl", "pt", "zh"]).optional(), + language: z.enum(["en", "de", "es", "fr", "hu", "it", "nl", "pl", "pt", "zh"]).optional(), mapFocus: z.enum(["trails", "location"]).optional(), location: z.object({ name: z.string(), diff --git a/web/src/lib/models/settings.ts b/web/src/lib/models/settings.ts index f73f6a8d..f57041af 100644 --- a/web/src/lib/models/settings.ts +++ b/web/src/lib/models/settings.ts @@ -3,7 +3,7 @@ import type { NotificationType } from "./notification"; class Settings { id?: string; unit?: "metric" | "imperial"; - language?: "en" | "de" | "fr" | "hu" | "it" | "nl" | "pl" | "pt" | "zh"; + language?: "en" | "de" | "es" | "fr" | "hu" | "it" | "nl" | "pl" | "pt" | "zh"; mapFocus?: "trails" | "location"; location?: { name: string, lat: number, lon: number }; category?: string; @@ -15,7 +15,7 @@ class Settings { constructor( unit: "metric" | "imperial", - language: "en" | "de" | "fr" | "hu" | "it" | "nl" | "pl" | "pt" | "zh", + language: "en" | "de" | "es" | "fr" | "hu" | "it" | "nl" | "pl" | "pt" | "zh", mapFocus: "trails" | "location", user: string, params?: { diff --git a/web/src/routes/settings/language/+page.svelte b/web/src/routes/settings/language/+page.svelte index c54fd5a9..c5684f41 100644 --- a/web/src/routes/settings/language/+page.svelte +++ b/web/src/routes/settings/language/+page.svelte @@ -15,6 +15,7 @@ { text: $_("chinese"), value: "zh" }, { text: $_("german"), value: "de" }, { text: $_("english"), value: "en" }, + { text: $_("spanish"), value: "es" }, { text: $_("french"), value: "fr" }, { text: $_("hungarian"), value: "hu" }, { text: $_("italian"), value: "it" }, @@ -33,11 +34,11 @@ async function handleLanguageSelection( value: "en" | "de" | "fr" | "hu" | "nl" | "pl" | "pt", ) { - locale.set(value); await settings_update({ id: settings!.id, language: value, }); + window.location.reload(); } async function handleUnitSelection(e: RadioItem) {