hyperformula icon indicating copy to clipboard operation
hyperformula copied to clipboard

HyperFormula.languages returns only `enGB`.

Open sequba opened this issue 2 years ago • 2 comments

Description

Reference about HyperFormula.languages property says:

Contains all available languages to use in registerLanguage.

Also, Localizing functions guide mentions this property as a way to get all the available languages.

Steps to reproduce

  1. Call HyperFormula.languages

Expected result: Get 16 supported languages. Actual result: Get only one language, enGB.

sequba avatar Jul 04 '22 11:07 sequba

Expected result: Get 16 supported languages.

Nope. Languages available for registerLanguage are those that are loaded on the page. If you don't attach additional files, they are not available. If someone loads his own languages then can even have 32 supported languages there.

Check any UMD language file:

if (!_.default.languages) {
  _.default.languages = {};
}

_.default.languages[dictionary.langCode] = dictionary;
var _default = dictionary;
exports.default = _default;

It's just an object that creates a namespace for languages so when loaded they will not pollute global scope. Documentation you're referring to mentions Hypefromula.languages only in UMD context. For ES modules property is not populated because modules are isolated (can't be done and it doesn't make sense anyway).

wojciechczerniak avatar Jul 04 '22 20:07 wojciechczerniak

Ok, I get it. Thanks @wojciechczerniak. In that case, the API reference for languages property should be updated.

  • [ ] Mention that this property is only useful for UMD modules.
  • [ ] Add link to the Localizing Functions guide that describes importing the language files.

sequba avatar Jul 06 '22 12:07 sequba

Closed with https://github.com/handsontable/hyperformula/pull/1348/files in HyperFormula 2.6.1

AMBudnik avatar Dec 27 '23 14:12 AMBudnik