From 63c6b523fb57d7156a7b8834d53eefb1975529b6 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 21 Mar 2024 12:14:54 +0100 Subject: [PATCH 1/7] refactor: refs #6425 new translation proposal --- src/i18n/index.js | 37 ++++++++++++++++++++++----- src/pages/Customer/CustomerFilter.vue | 15 ++++++----- src/pages/Customer/Translation/en.js | 8 ++++++ src/pages/Customer/Translation/es.js | 8 ++++++ src/pages/Entry/EntryFilter.vue | 17 +++++++----- src/pages/Entry/Translation/en.js | 14 ++++++++++ src/pages/Entry/Translation/es.js | 14 ++++++++++ src/pages/Travel/Translation/en.js | 8 ++++++ src/pages/Travel/Translation/es.js | 8 ++++++ src/pages/Travel/TravelFilter.vue | 10 +++----- 10 files changed, 114 insertions(+), 25 deletions(-) create mode 100644 src/pages/Customer/Translation/en.js create mode 100644 src/pages/Customer/Translation/es.js create mode 100644 src/pages/Entry/Translation/en.js create mode 100644 src/pages/Entry/Translation/es.js create mode 100644 src/pages/Travel/Translation/en.js create mode 100644 src/pages/Travel/Translation/es.js diff --git a/src/i18n/index.js b/src/i18n/index.js index a375812df..aee039001 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -1,9 +1,32 @@ -import en from './en'; -import es from './es'; -export const localeEquivalence = { - 'en':'en-GB' +const langs = import.meta.glob(`./**/*.js`); +const files = import.meta.glob(`../pages/**/Translation/en.js`); +const importLang = {}; + +for (const fileLang in langs) { + const lang = fileLang.split('/').at(1); + + import(fileLang) + .then((t) => { + importLang[lang] = t.default; + }) + .finally(() => { + for (const file in files) { + const splittedFile = file.split('/'); + splittedFile.pop(); + const langFiles = splittedFile.join('/') + '/' + lang + '.js'; + console.log('myFile: ', langFiles); + import(langFiles) + .then((t) => { + Object.assign(importLang[lang], t.default); + }) + .catch((err) => { + console.log('no va: ' + err, file, importLang); + }); + } + }); } -export default { - en: en, - es: es, + +export const localeEquivalence = { + en: 'en-GB', }; +export default importLang; diff --git a/src/pages/Customer/CustomerFilter.vue b/src/pages/Customer/CustomerFilter.vue index 593b45509..f9678c242 100644 --- a/src/pages/Customer/CustomerFilter.vue +++ b/src/pages/Customer/CustomerFilter.vue @@ -48,13 +48,17 @@ const zones = ref(); - + @@ -170,8 +174,7 @@ en: params: search: Contains fi: FI - name: Name - socialName: Social Name + salesPersonFk: Salesperson provinceFk: Province city: City @@ -193,8 +196,8 @@ es: zoneFk: Zona postcode: CP FI: NIF - Name: Nombre - Social Name: Razón social + + Salesperson: Comercial Province: Provincia City: Ciudad diff --git a/src/pages/Customer/Translation/en.js b/src/pages/Customer/Translation/en.js new file mode 100644 index 000000000..7e722c18d --- /dev/null +++ b/src/pages/Customer/Translation/en.js @@ -0,0 +1,8 @@ +export default { + customerFilter: { + filter: { + name: 'Name', + socialName: 'Social name', + }, + }, +}; diff --git a/src/pages/Customer/Translation/es.js b/src/pages/Customer/Translation/es.js new file mode 100644 index 000000000..180b44ab6 --- /dev/null +++ b/src/pages/Customer/Translation/es.js @@ -0,0 +1,8 @@ +export default { + customerFilter: { + filter: { + name: 'Nombre', + socialName: 'Razón Social', + }, + }, +}; diff --git a/src/pages/Entry/EntryFilter.vue b/src/pages/Entry/EntryFilter.vue index 22ddf0bbf..86c1f6b23 100644 --- a/src/pages/Entry/EntryFilter.vue +++ b/src/pages/Entry/EntryFilter.vue @@ -1,6 +1,8 @@