|
| 1 | +# Internationalization features |
| 2 | + |
| 3 | +Configure HyperFormula to match the languages and regions of your users. |
| 4 | + |
| 5 | +**Contents:** |
| 6 | +[[toc]] |
| 7 | + |
| 8 | +## Function names and errors |
| 9 | + |
| 10 | +Each of HyperFormula's [built-in functions](built-in-functions.md) and [errors](types-of-errors.md) is available in [17 languages](localizing-functions.md#list-of-supported-languages). |
| 11 | + |
| 12 | +You can easily [switch between languages](localizing-functions.md) ([`language`](../api/interfaces/configparams.md#language)). |
| 13 | + |
| 14 | +When adding a [custom function](custom-functions.md), you can define the function's [name](custom-functions.md#_3-add-your-function-s-names) in every language that you support. |
| 15 | + |
| 16 | +To support more languages, add a [custom language pack](localizing-functions.md). |
| 17 | + |
| 18 | +## Date and time formats |
| 19 | + |
| 20 | +To match a region's calendar conventions, you can set multiple date formats ([`dateFormats`](../api/interfaces/configparams.md#dateformats)) and time formats ([`timeFormats`](../api/interfaces/configparams.md#timeformats)). |
| 21 | + |
| 22 | +By default, HyperFormula uses the European date and time formats. [You can easily change them](date-and-time-handling.md#example). |
| 23 | + |
| 24 | +You can also add custom ways of [handling dates and times](date-and-time-handling.md#custom-date-and-time-handling). |
| 25 | + |
| 26 | +## Number format |
| 27 | + |
| 28 | +To match a region's number format, configure HyperFormula's decimal separator ([`decimalSeparator`](../api/interfaces/configparams.md#decimalseparator)) and thousands separator ([`thousandSeparator`](../api/interfaces/configparams.md#thousandseparator)). |
| 29 | + |
| 30 | +By default, HyperFormula uses the European number format (`1000000.00`): |
| 31 | + |
| 32 | +```js |
| 33 | +decimalSeparator: '.', // set by default |
| 34 | +thousandSeparator: '', // set by default |
| 35 | +``` |
| 36 | + |
| 37 | +To use the US number format (`1,000,000.00`), set: |
| 38 | + |
| 39 | +```js |
| 40 | +decimalSeparator: '.', // set by default |
| 41 | +thousandSeparator: ',', |
| 42 | +``` |
| 43 | + |
| 44 | +::: tip |
| 45 | + In HyperFormula, both [`decimalSeparator`](../api/interfaces/configparams.md#decimalseparator) and [`thousandSeparator`](../api/interfaces/configparams.md#thousandseparator) must be different from [`functionArgSeparator`](../api/interfaces/configparams.md#functionargseparator). |
| 46 | + In some cases it might cause compatibility issues with other spreadsheets, e.g., [Microsoft Excel](compatibility-with-microsoft-excel.md#separators) or [Google Sheets](compatibility-with-google-sheets.md#separators). |
| 47 | +::: |
| 48 | + |
| 49 | +## Currency symbol |
| 50 | + |
| 51 | +To match your users' currency, you can configure multiple currency symbols ([`currencySymbol`](../api/interfaces/configparams.md#currencysymbol)). |
| 52 | + |
| 53 | +The default currency symbol is `$`. To add `USD` as an alternative, set: |
| 54 | + |
| 55 | +```js |
| 56 | +currencySymbol: ['$', 'USD'], |
| 57 | +``` |
| 58 | + |
| 59 | +## String comparison rules |
| 60 | + |
| 61 | +To make sure that language-sensitive strings are compared in line with your users' language (e.g., `Préservation` vs. `Preservation`), set HyperFormula's [string comparison rules](types-of-operators.md#comparing-strings) ([`localeLang`](../api/interfaces/configparams.md#localelang)). |
| 62 | + |
| 63 | +The value of [`localeLang`](../api/interfaces/configparams.md#localelang) is processed by [`Intl.Collator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator), a JavaScript standard object. |
| 64 | + |
| 65 | +The default setting is: |
| 66 | + |
| 67 | +```js |
| 68 | +localeLang: 'en', // set by default |
| 69 | +``` |
| 70 | + |
| 71 | +To set the `en-US` string comparison rules, set: |
| 72 | + |
| 73 | +```js |
| 74 | +localeLang: 'en-US', |
| 75 | +``` |
| 76 | + |
| 77 | +To further customize string comparison rules, use these options: |
| 78 | +- [`caseSensitive`](../api/interfaces/configparams.md#casesensitive) |
| 79 | +- [`accentSensitive`](../api/interfaces/configparams.md#accentsensitive) |
| 80 | +- [`caseFirst`](../api/interfaces/configparams.md#casefirst) |
| 81 | +- [`ignorePunctuation`](../api/interfaces/configparams.md#ignorepunctuation) |
| 82 | + |
| 83 | +## Compatibility with other spreadsheet software |
| 84 | + |
| 85 | +For information on compatibility with locale-dependent syntax in other spreadsheet software, see: |
| 86 | +- [Compatibility with Microsoft Excel](compatibility-with-microsoft-excel.md) |
| 87 | +- [Compatibility with Google Sheets](compatibility-with-google-sheets.md) |
| 88 | + |
| 89 | +## `en-US` configuration |
| 90 | + |
| 91 | +This configuration aligns HyperFormula with the `en-US` locale. Due to the configuration of [separators](#number-format), it might not be fully compatible with formulas coming from other spreadsheet software. |
| 92 | + |
| 93 | +```js |
| 94 | +language: 'enUS', |
| 95 | +dateFormats: ['MM/DD/YYYY', 'MM/DD/YY', 'YYYY/MM/DD'], |
| 96 | +timeFormats: ['hh:mm', 'hh:mm:ss.sss'], // set by default |
| 97 | +decimalSeparator: '.', // set by default |
| 98 | +thousandSeparator: ',', |
| 99 | +functionArgSeparator: ';', // might cause incompatibility with other spreadsheets |
| 100 | +currencySymbol: ['$', 'USD'], |
| 101 | +localeLang: 'en-US', |
| 102 | +``` |
| 103 | + |
| 104 | +## `en-US` demo |
| 105 | + |
| 106 | +This demo shows HyperFormula configured for the `en-US` locale. |
| 107 | + |
| 108 | +<iframe |
| 109 | + src="https://codesandbox.io/embed/github/handsontable/hyperformula-demos/tree/2.2.x/i18n?autoresize=1&fontsize=11&hidenavigation=1&theme=light&view=preview" |
| 110 | + style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" |
| 111 | + title="handsontable/hyperformula-demos: basic-operations" |
| 112 | + allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" |
| 113 | + sandbox="allow-autoplay allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"> |
| 114 | +</iframe> |
0 commit comments