From 172d353df7a86baa9c2759907c7f855679138cc0 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 7 Oct 2022 17:38:08 +0200 Subject: [PATCH] fix: make sure subscription strings work consistently across languages --- src/components/misc/subscription.vue | 65 ++++++++++++++++++++++++---- src/i18n/lang/en.json | 21 ++++++--- 2 files changed, 72 insertions(+), 14 deletions(-) diff --git a/src/components/misc/subscription.vue b/src/components/misc/subscription.vue index ba0f79ef6..ccfa358f4 100644 --- a/src/components/misc/subscription.vue +++ b/src/components/misc/subscription.vue @@ -69,17 +69,38 @@ const emit = defineEmits(['update:modelValue']) const subscriptionService = shallowRef(new SubscriptionService()) const {t} = useI18n({useScope: 'global'}) + const tooltipText = computed(() => { if (disabled.value) { - return t('task.subscription.subscribedThroughParent', { - entity: props.entity, - parent: subscriptionEntity.value, - }) + if (props.entity === 'list' && subscriptionEntity.value === 'namespace') { + return t('task.subscription.subscribedListThroughParentNamespace') + } + if (props.entity === 'task' && subscriptionEntity.value === 'namespace') { + return t('task.subscription.subscribedTaskThroughParentNamespace') + } + if (props.entity === 'task' && subscriptionEntity.value === 'list') { + return t('task.subscription.subscribedTaskThroughParentList') + } + + return '' } - return props.modelValue !== null ? - t('task.subscription.subscribed', {entity: props.entity}) : - t('task.subscription.notSubscribed', {entity: props.entity}) + switch (props.entity) { + case 'namespace': + return props.modelValue !== null ? + t('task.subscription.subscribedNamespace') : + t('task.subscription.notSubscribedNamespace') + case 'list': + return props.modelValue !== null ? + t('task.subscription.subscribedList') : + t('task.subscription.notSubscribedList') + case 'task': + return props.modelValue !== null ? + t('task.subscription.subscribedTask') : + t('task.subscription.notSubscribedTask') + } + + return '' }) const buttonText = computed(() => props.modelValue ? t('task.subscription.unsubscribe') : t('task.subscription.subscribe')) @@ -105,7 +126,20 @@ async function subscribe() { }) await subscriptionService.value.create(subscription) emit('update:modelValue', subscription) - success({message: t('task.subscription.subscribeSuccess', {entity: props.entity})}) + + let message = '' + switch (props.entity) { + case 'namespace': + message = t('task.subscription.subscribeSuccessNamespace') + break + case 'list': + message = t('task.subscription.subscribeSuccessList') + break + case 'task': + message = t('task.subscription.subscribeSuccessTask') + break + } + success({message}) } async function unsubscribe() { @@ -115,6 +149,19 @@ async function unsubscribe() { }) await subscriptionService.value.delete(subscription) emit('update:modelValue', null) - success({message: t('task.subscription.unsubscribeSuccess', {entity: props.entity})}) + + let message = '' + switch (props.entity) { + case 'namespace': + message = t('task.subscription.unsubscribeSuccessNamespace') + break + case 'list': + message = t('task.subscription.unsubscribeSuccessList') + break + case 'task': + message = t('task.subscription.unsubscribeSuccessTask') + break + } + success({message}) } diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index 780ce3b79..3263b06c3 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -169,6 +169,7 @@ "title": "List Title", "color": "Color", "lists": "Lists", + "list": "List", "search": "Type to search for a list…", "searchSelect": "Click or press enter to select this list", "shared": "Shared Lists", @@ -675,13 +676,23 @@ "updated": "Updated" }, "subscription": { - "subscribedThroughParent": "You can't unsubscribe here because you are subscribed to this {entity} through its {parent}.", - "subscribed": "You are currently subscribed to this {entity} and will receive notifications for changes.", - "notSubscribed": "You are not subscribed to this {entity} and won't receive notifications for changes.", + "subscribedListThroughParentNamespace": "You can't unsubscribe here because you are subscribed to this list through its namespace.", + "subscribedTaskThroughParentNamespace": "You can't unsubscribe here because you are subscribed to this task through its namespace.", + "subscribedTaskThroughParentList": "You can't unsubscribe here because you are subscribed to this task through its list.", + "subscribedNamespace": "You are currently subscribed to this namespace and will receive notifications for changes.", + "notSubscribedNamespace": "You are not subscribed to this namespace and won't receive notifications for changes.", + "subscribedList": "You are currently subscribed to this list and will receive notifications for changes.", + "notSubscribedList": "You are not subscribed to this list and won't receive notifications for changes.", + "subscribedTask": "You are currently subscribed to this task and will receive notifications for changes.", + "notSubscribedTask": "You are not subscribed to this task and won't receive notifications for changes.", "subscribe": "Subscribe", "unsubscribe": "Unsubscribe", - "subscribeSuccess": "You are now subscribed to this {entity}", - "unsubscribeSuccess": "You are now unsubscribed to this {entity}" + "subscribeSuccessNamespace": "You are now subscribed to this namespace", + "unsubscribeSuccessNamespace": "You are now unsubscribed to this namespace", + "subscribeSuccessList": "You are now subscribed to this list", + "unsubscribeSuccessList": "You are now unsubscribed to this list", + "subscribeSuccessTask": "You are now subscribed to this task", + "unsubscribeSuccessTask": "You are now unsubscribed to this task" }, "attachment": { "title": "Attachments",