From aff0ebad50fddcf82a51d2d4999c770e467ac6f8 Mon Sep 17 00:00:00 2001 From: Johnpaul Chiwetelu <49923152+Myestery@users.noreply.github.com> Date: Thu, 19 Feb 2026 00:59:37 +0100 Subject: [PATCH] fix: reload template workflows when locale changes (#8963) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Templates were fetched once with the initial locale and cached behind an `isLoaded` guard. Changing language updated i18n UI strings but never re-fetched locale-specific template data (names, descriptions) from the server. - Extracts core template fetching into `fetchCoreTemplates()` and adds a `watch` on `i18n.global.locale` to re-fetch when the language changes. ## Test plan - [ ] Open the templates panel - [ ] Change language in settings (e.g. English -> French) - [ ] Verify template names and descriptions update without a page refresh - [ ] Verify initial load still works correctly ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8963-fix-reload-template-workflows-when-locale-changes-30b6d73d36508178a2f8c2c8947b5955) by [Unito](https://www.unito.io) --- .../repositories/workflowTemplatesStore.ts | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/platform/workflow/templates/repositories/workflowTemplatesStore.ts b/src/platform/workflow/templates/repositories/workflowTemplatesStore.ts index e78fd2278a..c3219f8d03 100644 --- a/src/platform/workflow/templates/repositories/workflowTemplatesStore.ts +++ b/src/platform/workflow/templates/repositories/workflowTemplatesStore.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia' -import { computed, ref, shallowRef } from 'vue' +import { computed, ref, shallowRef, watch } from 'vue' import { i18n, st } from '@/i18n' import { isCloud } from '@/platform/distribution/types' @@ -472,31 +472,32 @@ export const useWorkflowTemplatesStore = defineStore( return items }) + async function fetchCoreTemplates() { + const locale = i18n.global.locale.value + const [coreResult, englishResult, logoIndexResult] = await Promise.all([ + api.getCoreWorkflowTemplates(locale), + isCloud && locale !== 'en' + ? api.getCoreWorkflowTemplates('en') + : Promise.resolve([]), + fetchLogoIndex() + ]) + + coreTemplates.value = coreResult + englishTemplates.value = englishResult + logoIndex.value = logoIndexResult + + const coreNames = coreTemplates.value.flatMap((category) => + category.templates.map((template) => template.name) + ) + const customNames = Object.values(customTemplates.value).flat() + knownTemplateNames.value = new Set([...coreNames, ...customNames]) + } + async function loadWorkflowTemplates() { try { if (!isLoaded.value) { customTemplates.value = await api.getWorkflowTemplates() - const locale = i18n.global.locale.value - - const [coreResult, englishResult, logoIndexResult] = - await Promise.all([ - api.getCoreWorkflowTemplates(locale), - isCloud && locale !== 'en' - ? api.getCoreWorkflowTemplates('en') - : Promise.resolve([]), - fetchLogoIndex() - ]) - - coreTemplates.value = coreResult - englishTemplates.value = englishResult - logoIndex.value = logoIndexResult - - const coreNames = coreTemplates.value.flatMap((category) => - category.templates.map((template) => template.name) - ) - const customNames = Object.values(customTemplates.value).flat() - knownTemplateNames.value = new Set([...coreNames, ...customNames]) - + await fetchCoreTemplates() isLoaded.value = true } } catch (error) { @@ -504,6 +505,18 @@ export const useWorkflowTemplatesStore = defineStore( } } + watch( + () => i18n.global.locale.value, + async () => { + if (!isLoaded.value) return + try { + await fetchCoreTemplates() + } catch (error) { + console.error('Error reloading templates for new locale:', error) + } + } + ) + async function fetchLogoIndex(): Promise { try { const response = await fetch(api.fileURL('/templates/index_logo.json'))