From 73a25775e1cb7b1f1b355707e21e3704b98ca9c5 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 14 Sep 2023 21:10:18 +0300 Subject: [PATCH] Fix Swimlane Default title from "key default returned an object instead of string" to translated title of "Default". Thanks to titho85, hpvb and xet7 ! Fixes #4763, fixes #4742 --- client/components/lists/listBody.jade | 6 +-- client/components/lists/listBody.js | 25 ++++++++++ .../components/swimlanes/swimlaneHeader.jade | 6 ++- client/components/swimlanes/swimlaneHeader.js | 48 +++++++++++++++++++ 4 files changed, 80 insertions(+), 5 deletions(-) diff --git a/client/components/lists/listBody.jade b/client/components/lists/listBody.jade index 375d99f1b..3d319f1ca 100644 --- a/client/components/lists/listBody.jade +++ b/client/components/lists/listBody.jade @@ -79,18 +79,18 @@ template(name="linkCardPopup") select.js-select-boards option(value="") each boards - option(value="{{_id}}") {{title}} + option(value="{{_id}}") {{isTitleDefault title}} input.primary.confirm.js-link-board(type="button" value="{{_ 'link'}}") label {{_ 'swimlanes'}}: select.js-select-swimlanes each swimlanes - option(value="{{_id}}") {{title}} + option(value="{{_id}}") {{isTitleDefault title}} label {{_ 'lists'}}: select.js-select-lists each lists - option(value="{{_id}}") {{title}} + option(value="{{_id}}") {{isTitleDefault title}} label {{_ 'cards'}}: select.js-select-cards diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index d872d9305..502c9f48b 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -593,6 +593,31 @@ BlazeComponent.extendComponent({ }, }).register('linkCardPopup'); +Template.linkCardPopup.helpers({ + isTitleDefault(title) { + // https://github.com/wekan/wekan/issues/4763 + // https://github.com/wekan/wekan/issues/4742 + // Translation text for "default" does not work, it returns an object. + // When that happens, try use translation "defaultdefault" that has same content of default, or return text "Default". + // This can happen, if swimlane does not have name. + // Yes, this is fixing the symptom (Swimlane title does not have title) + // instead of fixing the problem (Add Swimlane title when creating swimlane) + // because there could be thousands of swimlanes, adding name Default to all of them + // would be very slow. + if (title.startsWith("key 'default") && title.endsWith('returned an object instead of string.')) { + if (`${TAPi18n.__('defaultdefault')}`.startsWith("key 'default") && `${TAPi18n.__('defaultdefault')}`.endsWith('returned an object instead of string.')) { + return 'Default'; + } else { + return `${TAPi18n.__('defaultdefault')}`; + } + } else if (title === 'Default') { + return `${TAPi18n.__('defaultdefault')}`; + } else { + return title; + } + }, +}); + BlazeComponent.extendComponent({ mixins() { return []; diff --git a/client/components/swimlanes/swimlaneHeader.jade b/client/components/swimlanes/swimlaneHeader.jade index ba1697e48..edc6ad56a 100644 --- a/client/components/swimlanes/swimlaneHeader.jade +++ b/client/components/swimlanes/swimlaneHeader.jade @@ -17,9 +17,11 @@ template(name="swimlaneFixedHeader") | {{_ 'list-templates-swimlane'}} else if $eq title 'Board Templates' | {{_ 'board-templates-swimlane'}} + else if $eq title 'Default' + | {{_ 'defaultdefault'}} else +viewer - = title + | {{isTitleDefault title}} .swimlane-header-menu unless currentUser.isCommentOnly if currentUser.isBoardAdmin @@ -33,7 +35,7 @@ template(name="swimlaneFixedHeader") template(name="editSwimlaneTitleForm") .list-composer - input.list-name-input.full-line(type="text" value=title autofocus) + input.list-name-input.full-line(type="text" value="{{isTitleDefault title}}" autofocus) .edit-controls.clearfix button.primary.confirm(type="submit") {{_ 'save'}} a.fa.fa-times-thin.js-close-inlined-form diff --git a/client/components/swimlanes/swimlaneHeader.js b/client/components/swimlanes/swimlaneHeader.js index a30e8d5c0..afc90846e 100644 --- a/client/components/swimlanes/swimlaneHeader.js +++ b/client/components/swimlanes/swimlaneHeader.js @@ -1,3 +1,4 @@ +import { TAPi18n } from '/imports/i18n'; import { ReactiveCache } from '/imports/reactiveCache'; const { calculateIndexData } = Utils; @@ -33,6 +34,53 @@ Template.swimlaneFixedHeader.helpers({ isBoardAdmin() { return ReactiveCache.getCurrentUser().isBoardAdmin(); }, + isTitleDefault(title) { + // https://github.com/wekan/wekan/issues/4763 + // https://github.com/wekan/wekan/issues/4742 + // Translation text for "default" does not work, it returns an object. + // When that happens, try use translation "defaultdefault" that has same content of default, or return text "Default". + // This can happen, if swimlane does not have name. + // Yes, this is fixing the symptom (Swimlane title does not have title) + // instead of fixing the problem (Add Swimlane title when creating swimlane) + // because there could be thousands of swimlanes, adding name Default to all of them + // would be very slow. + if (title.startsWith("key 'default") && title.endsWith('returned an object instead of string.')) { + if (`${TAPi18n.__('defaultdefault')}`.startsWith("key 'default") && `${TAPi18n.__('defaultdefault')}`.endsWith('returned an object instead of string.')) { + return 'Default'; + } else { + return `${TAPi18n.__('defaultdefault')}`; + } + } else if (title === 'Default') { + return `${TAPi18n.__('defaultdefault')}`; + } else { + return title; + } + }, +}); + +Template.editSwimlaneTitleForm.helpers({ + isTitleDefault(title) { + // https://github.com/wekan/wekan/issues/4763 + // https://github.com/wekan/wekan/issues/4742 + // Translation text for "default" does not work, it returns an object. + // When that happens, try use translation "defaultdefault" that has same content of default, or return text "Default". + // This can happen, if swimlane does not have name. + // Yes, this is fixing the symptom (Swimlane title does not have title) + // instead of fixing the problem (Add Swimlane title when creating swimlane) + // because there could be thousands of swimlanes, adding name Default to all of them + // would be very slow. + if (title.startsWith("key 'default") && title.endsWith('returned an object instead of string.')) { + if (`${TAPi18n.__('defaultdefault')}`.startsWith("key 'default") && `${TAPi18n.__('defaultdefault')}`.endsWith('returned an object instead of string.')) { + return 'Default'; + } else { + return `${TAPi18n.__('defaultdefault')}`; + } + } else if (title === 'Default') { + return `${TAPi18n.__('defaultdefault')}`; + } else { + return title; + } + }, }); Template.swimlaneActionPopup.events({