From 08345f8cffb3c6440050c36cfd2ba2ca70ba6cc8 Mon Sep 17 00:00:00 2001 From: Suresh Kumar Gangumalla Date: Tue, 29 Oct 2024 19:08:58 +0530 Subject: [PATCH 1/7] Added support for multiple language files Added support to include separate langugage file for each language code in translation.json Signed-off-by: Suresh Kumar Gangumalla --- src/plugins/language.js | 50 ++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/src/plugins/language.js b/src/plugins/language.js index 63e50a85..5bae7c07 100644 --- a/src/plugins/language.js +++ b/src/plugins/language.js @@ -37,22 +37,45 @@ export default { ) const setLanguage = (language) => { - // define the dictionary - dictionary = translations[language] || {} - // set the current language in the reactive state - state.language = language - - // warnings - if (Object.keys(translations).length === 0) { - Log.warn( - 'No translations loaded. Please load a file with translations or specify a translations object manually' - ) - } if (language in translations === false) { + // Translations have not yet been provided + if (Object.keys(translations).length === 0) { + Log.warn( + 'No translations loaded. Please load a file with translations or specify a translations object manually' + ) + } Log.warn(`Language ${language} not available in the loaded translations`) + // set the current language in the reactive state + state.language = language + } else { + setDict(language).then(() => { + state.language = language + }) } } + const setDict = (language) => { + return new Promise((resolve) => { + const translationObj = translations[language] + if (typeof translationObj === 'object') { + dictionary = translationObj + resolve() + } else if (typeof translationObj === 'string') { + fetchJson(translationObj) + .then((result) => { + // save the translations for this language (to prevent loading twice) + translations[language] = result + // define the dictionary + dictionary = result + resolve() + }) + .catch((e) => { + Log.error(e) + }) + } + }) + } + const loadLanguageFile = (filePath) => { return fetchJson(filePath) .then((result) => { @@ -65,8 +88,9 @@ export default { const setTranslations = (translationsObject) => { translations = translationsObject - dictionary = translations[state.language] || {} - state.loaded++ + setDict(state.language).then(() => { + state.loaded++ + }) } if ('file' in options) { From eb34ef4cdbd8079556976c430aebc4e97e871af8 Mon Sep 17 00:00:00 2001 From: Suresh Kumar Gangumalla Date: Wed, 6 Nov 2024 15:00:13 +0530 Subject: [PATCH 2/7] Updated warning messages order Making sure logging only one warning as per context. Signed-off-by: Suresh Kumar Gangumalla --- src/plugins/language.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/language.js b/src/plugins/language.js index 5bae7c07..ec2ae02b 100644 --- a/src/plugins/language.js +++ b/src/plugins/language.js @@ -37,14 +37,14 @@ export default { ) const setLanguage = (language) => { - if (language in translations === false) { - // Translations have not yet been provided - if (Object.keys(translations).length === 0) { - Log.warn( - 'No translations loaded. Please load a file with translations or specify a translations object manually' - ) - } - Log.warn(`Language ${language} not available in the loaded translations`) + const warningMsg = + Object.keys(translations).length === 0 + ? 'No translations loaded. Please load a file with translations or specify a translations object manually' + : language in translations === false + ? `Language ${language} not available in the loaded translations` + : false + if (warningMsg) { + Log.warn(warningMsg) // set the current language in the reactive state state.language = language } else { From 81cf00d27b6a67ce0c2b331fc761c7df77548fc0 Mon Sep 17 00:00:00 2001 From: Suresh Kumar Gangumalla Date: Fri, 15 Nov 2024 16:19:17 +0530 Subject: [PATCH 3/7] Fixes cached router view holder's alpha issue with default transition, alpha is set to zero for previous route view holder element. if preivous route is configured to keep alive then that view is cached with holder alpha set to zero Now, if previous route has a custom transition and if it does not contain alpha related prop transition in 'before' or 'in' then holder's alpha will not get updated to 1 from zero set by previous route out transition Signed-off-by: Suresh Kumar Gangumalla --- src/router/router.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/router/router.js b/src/router/router.js index 93d0b2f9..d7a9c54f 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -168,6 +168,27 @@ export const navigate = async function () { } } else { holder = view[symbols.holder] + + // Check, whether cached view holder's alpha prop is exists in transition or not + let isAlphaPropExists = false + if (route.transition.before) { + if (Array.isArray(route.transition.before)) { + for (let i = 0; i < route.transition.before.length; i++) { + if (route.transition.before[i].prop === 'alpha') { + isAlphaPropExists = true + break + } + } + } else { + if (route.transition.before.prop === 'alpha') { + isAlphaPropExists = true + } + } + } + // set holder alpha when alpha prop is not exists in route transition + if (!isAlphaPropExists) { + holder.set('alpha', 1) + } } this[symbols.children].push(view) From 63cbde29be915d651dd4f1059820fb17769c3412 Mon Sep 17 00:00:00 2001 From: Chris Newton Date: Mon, 18 Nov 2024 11:31:40 +0000 Subject: [PATCH 4/7] feat(types): added hasFocus property to ComponentBase type --- index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.d.ts b/index.d.ts index 2fbe2933..bdbe35be 100644 --- a/index.d.ts +++ b/index.d.ts @@ -149,6 +149,11 @@ declare module '@lightningjs/blits' { } export type ComponentBase = { + /** + * Check if a component has focus + */ + hasFocus: boolean, + /** * Listen to events emitted by other components */ From af9a90211ee188430ae384e5231439af763df4ec Mon Sep 17 00:00:00 2001 From: Suresh Kumar Gangumalla Date: Tue, 19 Nov 2024 11:02:22 +0530 Subject: [PATCH 5/7] updated isAlphaPropExists to hasAlphaProp Signed-off-by: Suresh Kumar Gangumalla --- src/router/router.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/router/router.js b/src/router/router.js index d7a9c54f..2ff17ee4 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -170,23 +170,23 @@ export const navigate = async function () { holder = view[symbols.holder] // Check, whether cached view holder's alpha prop is exists in transition or not - let isAlphaPropExists = false + let hasAlphaProp = false if (route.transition.before) { if (Array.isArray(route.transition.before)) { for (let i = 0; i < route.transition.before.length; i++) { if (route.transition.before[i].prop === 'alpha') { - isAlphaPropExists = true + hasAlphaProp = true break } } } else { if (route.transition.before.prop === 'alpha') { - isAlphaPropExists = true + hasAlphaProp = true } } } // set holder alpha when alpha prop is not exists in route transition - if (!isAlphaPropExists) { + if (!hasAlphaProp) { holder.set('alpha', 1) } } From 7b21de3aa5036f5063a72a87a73f55200a02cb4a Mon Sep 17 00:00:00 2001 From: Suresh Kumar Gangumalla Date: Tue, 19 Nov 2024 14:08:23 +0530 Subject: [PATCH 6/7] Updated to false check Signed-off-by: Suresh Kumar Gangumalla --- src/router/router.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/router/router.js b/src/router/router.js index 2ff17ee4..6e4f3476 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -179,14 +179,12 @@ export const navigate = async function () { break } } - } else { - if (route.transition.before.prop === 'alpha') { - hasAlphaProp = true - } + } else if (route.transition.before.prop === 'alpha') { + hasAlphaProp = true } } // set holder alpha when alpha prop is not exists in route transition - if (!hasAlphaProp) { + if (hasAlphaProp === false) { holder.set('alpha', 1) } } From 34f884ebd9c524fcb6dcd6b326b788c211536bc5 Mon Sep 17 00:00:00 2001 From: Michiel van der Geest Date: Tue, 19 Nov 2024 17:37:17 +0100 Subject: [PATCH 7/7] Bumped version to 1.11.0 and updated changelog. --- CHANGELOG.md | 10 ++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc464c7d..2644c2e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## v1.11.0 + +_19 nov 2024_ + +- Added support for splitting up translation file per language +- Added hasFocus property to ComponentBase type +- Fixed issue with alpha during router transitions + + ## v1.10.1 _15 nov 2024_ @@ -7,6 +16,7 @@ _15 nov 2024_ - Upgraded to renderer 2.7.1 - Added documentation on Router + ## v1.10.0 _8 nov 2024_ diff --git a/package-lock.json b/package-lock.json index fd1856f3..59bd4126 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lightningjs/blits", - "version": "1.10.1", + "version": "1.11.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@lightningjs/blits", - "version": "1.10.1", + "version": "1.11.0", "license": "Apache-2.0", "dependencies": { "@lightningjs/msdf-generator": "^1.1.0", diff --git a/package.json b/package.json index ccce1df4..c8afe771 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lightningjs/blits", - "version": "1.10.1", + "version": "1.11.0", "description": "Blits: The Lightning 3 App Development Framework", "bin": "bin/index.js", "exports": {