From 94dd0dbae81970470a9990b23bb344805ed23f14 Mon Sep 17 00:00:00 2001 From: Kuba Sekowski Date: Wed, 15 Jan 2025 12:27:02 +0100 Subject: [PATCH] Fix registerLanguage() issue in the code examples (#1484) Make code examples check for registered languages before registering new ones --- docs/examples/i18n/example1.js | 4 +++- docs/examples/i18n/example1.ts | 4 +++- docs/examples/localizing-functions/example1.js | 4 +++- docs/examples/localizing-functions/example1.ts | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/examples/i18n/example1.js b/docs/examples/i18n/example1.js index 6f97e6e1a..16967ff0e 100644 --- a/docs/examples/i18n/example1.js +++ b/docs/examples/i18n/example1.js @@ -65,7 +65,9 @@ const config = { licenseKey: 'gpl-v3', }; -HyperFormula.registerLanguage('enUS', enUS); +if (!HyperFormula.getRegisteredLanguagesCodes().includes('enUS')) { + HyperFormula.registerLanguage('enUS', enUS); +} // Create an empty HyperFormula instance. const hf = HyperFormula.buildEmpty(config); diff --git a/docs/examples/i18n/example1.ts b/docs/examples/i18n/example1.ts index 4b48b0c7c..a59236f60 100644 --- a/docs/examples/i18n/example1.ts +++ b/docs/examples/i18n/example1.ts @@ -67,7 +67,9 @@ const config = { licenseKey: 'gpl-v3', }; -HyperFormula.registerLanguage('enUS', enUS); +if (!HyperFormula.getRegisteredLanguagesCodes().includes('enUS')) { + HyperFormula.registerLanguage('enUS', enUS); +} // Create an empty HyperFormula instance. const hf = HyperFormula.buildEmpty(config); diff --git a/docs/examples/localizing-functions/example1.js b/docs/examples/localizing-functions/example1.js index 0b9af1d2b..d7388ac47 100644 --- a/docs/examples/localizing-functions/example1.js +++ b/docs/examples/localizing-functions/example1.js @@ -28,7 +28,9 @@ const tableData = [ ]; // register language -HyperFormula.registerLanguage('frFR', frFR); +if (!HyperFormula.getRegisteredLanguagesCodes().includes('frFR')) { + HyperFormula.registerLanguage('frFR', frFR); +} // Create an empty HyperFormula instance. const hf = HyperFormula.buildEmpty({ diff --git a/docs/examples/localizing-functions/example1.ts b/docs/examples/localizing-functions/example1.ts index 2a827bed4..daa70fe05 100644 --- a/docs/examples/localizing-functions/example1.ts +++ b/docs/examples/localizing-functions/example1.ts @@ -30,7 +30,9 @@ const tableData = [ ]; // register language -HyperFormula.registerLanguage('frFR', frFR); +if (!HyperFormula.getRegisteredLanguagesCodes().includes('frFR')) { + HyperFormula.registerLanguage('frFR', frFR); +} // Create an empty HyperFormula instance. const hf = HyperFormula.buildEmpty({