mirror of
https://github.com/directus/directus.git
synced 2026-02-16 22:21:37 -05:00
prevent null translations from being merged (#12162)
This commit is contained in:
@@ -54,18 +54,24 @@ export const useCollectionsStore = defineStore({
|
||||
for (let i = 0; i < collection.meta.translations.length; i++) {
|
||||
const { language, translation, singular, plural } = collection.meta.translations[i];
|
||||
|
||||
const literalInterpolatedTranslation = translation ? translation.replace(/([{}@$|])/g, "{'$1'}") : '';
|
||||
const literalInterpolatedTranslation = translation ? translation.replace(/([{}@$|])/g, "{'$1'}") : null;
|
||||
|
||||
i18n.global.mergeLocaleMessage(language, {
|
||||
collection_names: {
|
||||
[collection.collection]: literalInterpolatedTranslation,
|
||||
},
|
||||
collection_names_singular: {
|
||||
[collection.collection]: singular,
|
||||
},
|
||||
collection_names_plural: {
|
||||
[collection.collection]: plural,
|
||||
},
|
||||
...(literalInterpolatedTranslation && {
|
||||
collection_names: {
|
||||
[collection.collection]: literalInterpolatedTranslation,
|
||||
},
|
||||
}),
|
||||
...(singular && {
|
||||
collection_names_singular: {
|
||||
[collection.collection]: singular,
|
||||
},
|
||||
}),
|
||||
...(plural && {
|
||||
collection_names_plural: {
|
||||
[collection.collection]: plural,
|
||||
},
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,14 +76,16 @@ export const useFieldsStore = defineStore({
|
||||
const { language, translation } = field.meta.translations[i];
|
||||
|
||||
// Interpolate special characters in vue-i18n to prevent parsing error. Ref #11287
|
||||
const literalInterpolatedTranslation = translation ? translation.replace(/([{}@$|])/g, "{'$1'}") : '';
|
||||
const literalInterpolatedTranslation = translation ? translation.replace(/([{}@$|])/g, "{'$1'}") : null;
|
||||
|
||||
i18n.global.mergeLocaleMessage(language, {
|
||||
fields: {
|
||||
[field.collection]: {
|
||||
[field.field]: literalInterpolatedTranslation,
|
||||
...(literalInterpolatedTranslation && {
|
||||
fields: {
|
||||
[field.collection]: {
|
||||
[field.field]: literalInterpolatedTranslation,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user