Changed Localization to JSON String

This commit is contained in:
2026-02-17 10:37:18 +02:00
parent 59c5049305
commit cb2c5c6aba
4 changed files with 59 additions and 20 deletions

View File

@@ -7,14 +7,16 @@ import {
getLanguageName,
normalizeColor,
formatDuration,
parseLocalizedString,
serializeLocalizedString,
} from "./melodyUtils";
const MELODY_TYPES = ["orthodox", "catholic", "all"];
const MELODY_TONES = ["normal", "festive", "cheerful", "lamentation"];
const defaultInfo = {
name: {},
description: {},
name: "",
description: "",
melodyTone: "normal",
customTags: [],
minSpeed: 0,
@@ -155,7 +157,9 @@ export default function MelodyForm() {
// Update a localized field for the current edit language
const updateLocalizedField = (fieldKey, text) => {
updateInfo(fieldKey, { ...information[fieldKey], [editLang]: text });
const dict = parseLocalizedString(information[fieldKey]);
dict[editLang] = text;
updateInfo(fieldKey, serializeLocalizedString(dict));
};
const handleSubmit = async (e) => {
@@ -836,8 +840,8 @@ export default function MelodyForm() {
setTranslationModal((prev) => ({ ...prev, open: false }))
}
field={translationModal.field}
value={information[translationModal.fieldKey] || {}}
onChange={(updated) => updateInfo(translationModal.fieldKey, updated)}
value={parseLocalizedString(information[translationModal.fieldKey])}
onChange={(updated) => updateInfo(translationModal.fieldKey, serializeLocalizedString(updated))}
languages={languages}
multiline={translationModal.multiline}
/>