mirror of
https://github.com/directus/directus.git
synced 2026-01-30 02:07:57 -05:00
Prevent literal interpolation on null translations & apply to collection translations (#11482)
* translation could be null in edge cases * add interpolation to collection translations
This commit is contained in:
@@ -54,9 +54,11 @@ 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'}") : '';
|
||||
|
||||
i18n.global.mergeLocaleMessage(language, {
|
||||
collection_names: {
|
||||
[collection.collection]: translation,
|
||||
[collection.collection]: literalInterpolatedTranslation,
|
||||
},
|
||||
collection_names_singular: {
|
||||
[collection.collection]: singular,
|
||||
|
||||
@@ -76,7 +76,7 @@ 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.replace(/([{}@$|])/g, "{'$1'}");
|
||||
const literalInterpolatedTranslation = translation ? translation.replace(/([{}@$|])/g, "{'$1'}") : '';
|
||||
|
||||
i18n.global.mergeLocaleMessage(language, {
|
||||
fields: {
|
||||
|
||||
Reference in New Issue
Block a user