From f6fb35ec404ddae73917c9e62ff2927b83c4a9ca Mon Sep 17 00:00:00 2001 From: Christian Beutel <> Date: Sun, 31 Mar 2024 13:10:51 +0200 Subject: [PATCH] adds hungarian translation --- db/migrations/1711883208_updated_users.go | 81 +++++++++++++++++++++++ web/src/lib/i18n/index.ts | 1 + web/src/lib/i18n/locales/de.json | 3 +- web/src/lib/i18n/locales/en.json | 3 +- web/src/lib/i18n/locales/fr.json | 3 +- web/src/lib/i18n/locales/hu.json | 4 +- web/src/lib/i18n/locales/nl.json | 3 +- web/src/lib/i18n/locales/pl.json | 3 +- web/src/lib/i18n/locales/pt.json | 3 +- web/src/lib/stores/user_store.ts | 4 +- web/src/routes/profile/+page.svelte | 3 +- web/src/routes/register/+page.svelte | 13 +++- 12 files changed, 112 insertions(+), 12 deletions(-) create mode 100644 db/migrations/1711883208_updated_users.go diff --git a/db/migrations/1711883208_updated_users.go b/db/migrations/1711883208_updated_users.go new file mode 100644 index 00000000..6197563d --- /dev/null +++ b/db/migrations/1711883208_updated_users.go @@ -0,0 +1,81 @@ +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("_pb_users_auth_") + if err != nil { + return err + } + + // update + edit_language := &schema.SchemaField{} + json.Unmarshal([]byte(`{ + "system": false, + "id": "t1wlsqyp", + "name": "language", + "type": "select", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "en", + "de", + "fr", + "hu", + "nl", + "pl", + "pt" + ] + } + }`), edit_language) + collection.Schema.AddField(edit_language) + + return dao.SaveCollection(collection) + }, func(db dbx.Builder) error { + dao := daos.New(db); + + collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_") + if err != nil { + return err + } + + // update + edit_language := &schema.SchemaField{} + json.Unmarshal([]byte(`{ + "system": false, + "id": "t1wlsqyp", + "name": "language", + "type": "select", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "en", + "de", + "fr", + "nl", + "pl", + "pt" + ] + } + }`), edit_language) + collection.Schema.AddField(edit_language) + + return dao.SaveCollection(collection) + }) +} diff --git a/web/src/lib/i18n/index.ts b/web/src/lib/i18n/index.ts index b4061a49..09765808 100644 --- a/web/src/lib/i18n/index.ts +++ b/web/src/lib/i18n/index.ts @@ -8,6 +8,7 @@ const defaultLocale = 'en' register('en', () => import('./locales/en.json')) register('de', () => import('./locales/de.json')) register('fr', () => import('./locales/fr.json')) +register('hu', () => import('./locales/hu.json')) register('nl', () => import('./locales/nl.json')) register('pl', () => import('./locales/pl.json')) register('pt', () => import('./locales/pt.json')) diff --git a/web/src/lib/i18n/locales/de.json b/web/src/lib/i18n/locales/de.json index 0aa31d83..0b63db54 100644 --- a/web/src/lib/i18n/locales/de.json +++ b/web/src/lib/i18n/locales/de.json @@ -62,6 +62,7 @@ "hero_section_1_text": "Hier sind einige Routen, die dir gefallen könnten. Oder du wirfst einen Blick auf die vollständige Liste.", "hero_section_1_text_alternative": "Speichere dein letztes Abenteuer, um loszulegen.", "hero_section_2_text": "Wusstest du schon? Du kannst nicht nur deine Routen speichern. Es gibt viele Kategorien für alle deine Abenteuer.", + "hungarian": "Ungarisch", "icon": "Icon", "imperial": "Amerikanisch", "invalid-date": "Ungültiges Datum", @@ -79,7 +80,7 @@ "map": "Karte", "metric": "Metrisch", "moderate": "Mittel", - "must-be-at-least-8-characters-long": "Muss mindestens 8 Zeichen lang sein", + "must-be-at-least-n-characters-long": "Muss mindestens {n} Zeichen lang sein", "name": "Name", "near": "Nahe", "new-list": "Neue Liste", diff --git a/web/src/lib/i18n/locales/en.json b/web/src/lib/i18n/locales/en.json index 0ae2d5f7..16d16269 100644 --- a/web/src/lib/i18n/locales/en.json +++ b/web/src/lib/i18n/locales/en.json @@ -62,6 +62,7 @@ "hero_section_1_text": "Here are some trails you might like. Or you can just go to the full list right now.", "hero_section_1_text_alternative": "Get started by saving your latest adventure.", "hero_section_2_text": "Did you know? You cannot only save you hiking trails. There are many categories for all your adventures.", + "hungarian": "Hungarian", "icon": "Icon", "imperial": "Imperial", "invalid-date": "Invalid Date", @@ -79,7 +80,7 @@ "map": "Map", "metric": "Metric", "moderate": "Moderate", - "must-be-at-least-8-characters-long": "Must be at least 8 characters long", + "must-be-at-least-n-characters-long": "Must be at least {n} characters long", "name": "Name", "near": "Near", "new-list": "New List", diff --git a/web/src/lib/i18n/locales/fr.json b/web/src/lib/i18n/locales/fr.json index dd7d318d..e37654f7 100644 --- a/web/src/lib/i18n/locales/fr.json +++ b/web/src/lib/i18n/locales/fr.json @@ -62,6 +62,7 @@ "hero_section_1_text": "Voici quelques itinéraires qui pourraient vous plaire. Vous pouvez également consulter la liste complète dès maintenant.", "hero_section_1_text_alternative": "Commencez par enregistrer votre dernière aventure.", "hero_section_2_text": "Le saviez-vous ? Vous ne pouvez pas vous contenter que de sauver vos itinéraires de randonnée. Il existe de nombreuses catégories pour toutes vos aventures.", + "hungarian": "Hongrois", "icon": "Icône", "imperial": "Impérial", "invalid-date": "Date invalide", @@ -79,7 +80,7 @@ "map": "Carte", "metric": "Métrique", "moderate": "Modérer", - "must-be-at-least-8-characters-long": "Doit être composé d'au moins 8 caractères", + "must-be-at-least-n-characters-long": "Doit être composé d'au moins {n} caractères", "name": "Nom", "near": "Proche", "new-list": "Nouvelle liste", diff --git a/web/src/lib/i18n/locales/hu.json b/web/src/lib/i18n/locales/hu.json index 101ed6c5..7da4b0a4 100644 --- a/web/src/lib/i18n/locales/hu.json +++ b/web/src/lib/i18n/locales/hu.json @@ -62,7 +62,7 @@ "hero_section_1_text": "Íme néhány nyomvonal, amely tetszeni fog. Vagy csak menj a teljes listára most rögtön.", "hero_section_1_text_alternative": "Kezdje a legújabb kaland elmentésével.", "hero_section_2_text": "Tudta? Nem csak a túraútvonalakat mentheti el. Számos kategória létezik minden kalandodhoz.", - "hungary": "Magyar", + "hungarian": "Magyar", "icon": "Ikon", "imperial": "Angolszász", "invalid-date": "Érvénytelen dátum", @@ -80,7 +80,7 @@ "map": "Térkép", "metric": "Metrikus", "moderate": "Mérsékelt", - "must-be-at-least-8-characters-long": "Legalább 8 karakter hosszúnak kell lennie", + "must-be-at-least-n-characters-long": "Legalább {n} karakter hosszúnak kell lennie", "name": "Név", "near": "Közelben", "new-list": "Új lista", diff --git a/web/src/lib/i18n/locales/nl.json b/web/src/lib/i18n/locales/nl.json index c2f0d994..d6972083 100644 --- a/web/src/lib/i18n/locales/nl.json +++ b/web/src/lib/i18n/locales/nl.json @@ -62,6 +62,7 @@ "hero_section_1_text": "Hier zijn enkele routes die je misschien leuk vindt. Of je kan ook de volledige lijst bekijken.", "hero_section_1_text_alternative": "Sla je laatste avontuur op om te beginnen.", "hero_section_2_text": "Wist je dat? Je kan niet alleen wandelroutes opslaan. Er zijn verschillende categorieën voor al je avonturen.", + "hungarian": "Hongaars", "icon": "Icoon", "imperial": "Amerikaans", "invalid-date": "Ongeldige datum", @@ -79,7 +80,7 @@ "map": "Kaart", "metric": "Metrisch", "moderate": "Gemiddeld", - "must-be-at-least-8-characters-long": "Moet minstens 8 karakters lang zijn", + "must-be-at-least-n-characters-long": "Moet minstens {n} karakters lang zijn", "name": "Naam", "near": "Dichtbij", "new-list": "Nieuwe lijst", diff --git a/web/src/lib/i18n/locales/pl.json b/web/src/lib/i18n/locales/pl.json index 6129bde3..974e63ce 100644 --- a/web/src/lib/i18n/locales/pl.json +++ b/web/src/lib/i18n/locales/pl.json @@ -62,6 +62,7 @@ "hero_section_1_text": "Oto kila ścieżek które możesz zobaczyć lub możesz przejść do pełnej listy.", "hero_section_1_text_alternative": "Zacznij poprzez zapisanie swojej ostatniej wyprawy.", "hero_section_2_text": "Czy wiesz że, możesz zapisywać nie tylko piesze wycieczki ale także inne kategorie wypraw?", + "hungarian": "Język węgierski", "icon": "Ikona", "imperial": "Anglosaskie", "invalid-date": "Nieprawidłowa data", @@ -79,7 +80,7 @@ "map": "Mapa", "metric": "Metryczne", "moderate": "Średnia", - "must-be-at-least-8-characters-long": "Długość musi wynosić przynajmniej 8 znaków", + "must-be-at-least-n-characters-long": "Długość musi wynosić przynajmniej {n} znaków", "name": "Nazwa", "near": "Blisko", "new-list": "Nowa Lista", diff --git a/web/src/lib/i18n/locales/pt.json b/web/src/lib/i18n/locales/pt.json index 0df1dbc0..b7f1cf0f 100644 --- a/web/src/lib/i18n/locales/pt.json +++ b/web/src/lib/i18n/locales/pt.json @@ -62,6 +62,7 @@ "hero_section_1_text": "Aqui estão algumas trilhas que você pode gostar. Ou podes ir à lista completa agora.", "hero_section_1_text_alternative": "Comece salvando sua última aventura.", "hero_section_2_text": "Sabias? Você não pode apenas salvá-lo trilhas de caminhada. Há muitas categorias para todas as suas aventuras.", + "hungarian": "Húngaro", "icon": "Ícone", "imperial": "Imperial", "invalid-date": "Data inválida", @@ -79,7 +80,7 @@ "map": "Mapa", "metric": "Métrica", "moderate": "Moderado", - "must-be-at-least-8-characters-long": "Deve ter pelo menos 8 caracteres", + "must-be-at-least-n-characters-long": "Deve ter pelo menos {n} caracteres", "name": "Nome", "near": "Próximo", "new-list": "Nova lista", diff --git a/web/src/lib/stores/user_store.ts b/web/src/lib/stores/user_store.ts index 7f73102e..d4db0883 100644 --- a/web/src/lib/stores/user_store.ts +++ b/web/src/lib/stores/user_store.ts @@ -9,7 +9,7 @@ export type User = { password: string, avatar?: string; unit?: "metric" | "imperial"; - language?: "en" | "de" | "fr" | "nl" | "pl" | "pt"; + language?: "en" | "de" | "fr" | "hu" | "nl" | "pl" | "pt"; location?: { name: string, lat: number, lon: number } } @@ -62,7 +62,7 @@ export async function oauth_login(data: { name: string, code: string, codeVerifi const r = await fetch('/api/v1/auth/oauth', { method: 'POST', body: JSON.stringify(data) - }) + }) if (r.ok) { pb.authStore.loadFromCookie(document.cookie) diff --git a/web/src/routes/profile/+page.svelte b/web/src/routes/profile/+page.svelte index 61ef3236..02d52050 100644 --- a/web/src/routes/profile/+page.svelte +++ b/web/src/routes/profile/+page.svelte @@ -25,6 +25,7 @@ { text: $_("german"), value: "de" }, { text: $_("english"), value: "en" }, { text: $_("french"), value: "fr" }, + { text: $_("hungarian"), value: "hu" }, { text: $_("dutch"), value: "nl" }, { text: $_("polish"), value: "pl" }, { text: $_("portuguese"), value: "pt" }, @@ -95,7 +96,7 @@ } async function handleLanguageSelection( - value: "en" | "de" | "fr" | "nl" | "pl" | "pt", + value: "en" | "de" | "fr" | "hu" | "nl" | "pl" | "pt", ) { locale.set(value); await users_update({ diff --git a/web/src/routes/register/+page.svelte b/web/src/routes/register/+page.svelte index 4d2f6cfa..a264efb4 100644 --- a/web/src/routes/register/+page.svelte +++ b/web/src/routes/register/+page.svelte @@ -20,13 +20,24 @@ }, validationSchema: object({ username: string() + .min( + 3, + $_("must-be-at-least-n-characters-long", { + values: { n: 3 }, + }), + ) .required($_("required")) .matches(/^[\w][\w\.]*$/, { message: $_("invalid-username") }), email: string() .email($_("not-a-valid-email-address")) .required($_("required")), password: string() - .min(8, $_("must-be-at-least-8-characters-long")) + .min( + 8, + $_("must-be-at-least-n-characters-long", { + values: { n: 8 }, + }), + ) .required($_("required")), }), onSubmit: async (newUser) => {