Skip to content

Commit

Permalink
Fix registerLanguage() issue in the code examples (#1484)
Browse files Browse the repository at this point in the history
Make code examples check for registered languages before registering new ones
  • Loading branch information
sequba authored Jan 15, 2025
1 parent cdb234e commit 94dd0db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/examples/i18n/example1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/i18n/example1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/localizing-functions/example1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/localizing-functions/example1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 94dd0db

Please # to comment.