Skip to content

Commit fdf9bf2

Browse files
authored
Merge pull request #22 from DHTMLX/formulas-descriptions-popup-4885
[update] add sections for popup with formula description into related guides
2 parents cc0223f + bb058d9 commit fdf9bf2

File tree

3 files changed

+153
-13
lines changed

3 files changed

+153
-13
lines changed

docs/assets/formula_popup.png

11.9 KB
Loading

docs/functions.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,9 +1311,17 @@ Check the example in our [snippet tool](https://snippet.dhtmlx.com/wux2b35b).
13111311

13121312
## Getting cell formula
13131313

1314-
Starting with v4.1, you can get the formula applied to a cell via the [getFormula()](api/spreadsheet_getformula_method.md) method. The method takes the id of the cell as a parameter:
1314+
Starting with v4.1, you can get the formula applied to a cell via the [`getFormula()`](api/spreadsheet_getformula_method.md) method. The method takes the id of the cell as a parameter:
13151315

1316-
```js
1316+
~~~js
13171317
var formula = spreadsheet.getFormula("B2");
13181318
// -> "ABS(C2)"
1319-
```
1319+
~~~
1320+
1321+
## Popup with formula description
1322+
1323+
When you enter a formula, a popup with description of the function and its parameters appears.
1324+
1325+
![Popup with formula description](assets/formula_popup.png)
1326+
1327+
You can modify the default locale for the popup with formula parameters and add a custom locale. Check the details in the [Localization](localization.md/#default-locale-for-formulas) guide.

docs/localization.md

Lines changed: 142 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const en = {
2727
italic: "Italic",
2828
underline: "Underline",
2929
strikethrough: "Strikethrough",
30-
30+
3131
link: "Link",
3232

3333
halign: "Horizontal align",
@@ -53,11 +53,24 @@ const en = {
5353

5454
columns: "Columns",
5555
rows: "Rows",
56-
addColumn: "Add column",
56+
addColumn: "Add column left",
5757
removeColumn: "Remove column",
5858
fitToData: "Fit to data",
59-
addRow: "Add row",
59+
addRow: "Add row above",
6060
removeRow: "Remove row",
61+
row: "row",
62+
col: "col",
63+
freeze: "Freeze",
64+
freezeToCol: "Freeze up to column {col}",
65+
freezeToRow: "Freeze up to row {row}",
66+
unfreezeRows: "Unfreeze rows",
67+
unfreezeCols: "Unfreeze columns",
68+
hideCol: "Hide column {col}",
69+
hideCols: "Hide columns {col}",
70+
showCols: "Show columns",
71+
hideRows: "Hide rows {row}",
72+
hideRow: "Hide row {row}",
73+
showRows: "Show rows",
6174

6275
format: "Format",
6376
common: "Common",
@@ -72,6 +85,22 @@ const en = {
7285

7386
help: "Help",
7487

88+
custom: "Custom",
89+
90+
border: "Border",
91+
border_all: "All borders",
92+
border_inner: "Inner borders",
93+
border_horizontal: "Horizontal borders",
94+
border_vertical: "Vertical borders",
95+
border_outer: "Outer borders",
96+
border_color: "Border color",
97+
border_left: "Left border",
98+
border_top: "Top border",
99+
border_right: "Right border",
100+
border_bottom: "Bottom border",
101+
border_clear: "Clear borders",
102+
border_style: "Border style",
103+
75104
// Tabbar
76105
deleteSheet: "Delete",
77106
renameSheet: "Rename",
@@ -91,15 +120,16 @@ const en = {
91120
ascSort: "Sort A to Z",
92121
descSort: "Sort Z to A",
93122

94-
// Actions
123+
//Actions
95124
copy: "Copy",
96125
edit: "Edit",
97126
insert: "Insert",
98127
remove: "Remove",
99128
linkCopied: "Link copied to clipboard",
100129

101-
// Filter
102-
e:"Is empty",
130+
131+
//filter
132+
e: "Is empty",
103133
ne: "Is not empty",
104134
tc: "Text contains",
105135
tdc: "Text doesn't contain",
@@ -114,17 +144,18 @@ const en = {
114144
lt: "Less than",
115145
leq: "Less or equal to",
116146
eq: "Is equal to",
117-
neq:"Is not equal to",
147+
neq: "Is not equal to",
118148
ib: "Is between",
119149
inb: "Is not between",
120150

121151
none: "None",
122-
empty: "Empty",
123152
value: "Value",
124153
values: "By values",
125154
condition: "By condition",
126155
and: "And",
127156

157+
blank: "(Blank)",
158+
128159
// Buttons
129160
cancel: "Cancel",
130161
save: "Save",
@@ -142,14 +173,115 @@ const en = {
142173
spanPasteError: "You can't paste merges that cross the boundary of a frozen region",
143174
spanMergeLockedError: "You can't merge locked cells!",
144175
spanUnmergeLockedError: "You can't unmerge locked cells!",
176+
spanOverFilteredRow: "You can't merge cells over a filtered row.",
177+
removeAlert: "You can't remove last $name!",
145178
};
146179
~~~
147180

148181
## Custom locale
149182

150183
To apply a different locale you need to:
151184

152-
- provide translation for all text labels in Spreadsheet, e.g. the Russian locale looks like this
153-
- apply the new locale by calling the **dhx.i18n.setLocale()** method before initializing Spreadsheet
185+
- provide translations for all text labels in Spreadsheet, e.g. for the Russian locale:
186+
187+
~~~jsx
188+
const ru = {
189+
// language settings
190+
};
191+
~~~
192+
193+
- apply the new locale by calling the `dhx.i18n.setLocale()` method before initializing Spreadsheet:
194+
195+
~~~jsx
196+
dhx.i18n.setLocale("spreadsheet", ru);
197+
const spreadsheet = new dhx.Spreadsheet("spreadsheet_container");
198+
~~~
199+
200+
## Default locale for formulas
201+
202+
The i18n locale for the Spreadsheet popup with formulas is contained in the `dhx.i18n.formulas` object. The default locale for formulas is the following:
203+
204+
~~~jsx
205+
const en = {
206+
SUM: [
207+
[
208+
"Number1",
209+
"Required. The first value to sum."
210+
],
211+
[
212+
"Number2",
213+
"Optional. The second value to sum."
214+
],
215+
[
216+
"Number3",
217+
"Optional. The third value to sum."
218+
]
219+
],
220+
AVERAGE: [
221+
[
222+
"Number1",
223+
"Required. A number or cell reference that refers to numeric values."
224+
],
225+
[
226+
"Number2",
227+
"Optional. A number or cell reference that refers to numeric values."
228+
]
229+
],
230+
// more formulas' descriptions
231+
};
232+
~~~
233+
234+
You can check the full default locale for formulas in the [HTML tab of the related snippet](https://snippet.dhtmlx.com/yn5hyyim).
235+
236+
## Custom locale for formulas
237+
238+
To apply a custom locale for Spreadsheet formulas, you need to use the `dhx.i18n.setLocale()` method in the following way:
239+
240+
~~~jsx
241+
dhx.i18n.setLocale(
242+
"formulas",
243+
locale: {
244+
// the structure of the formulas in the locale
245+
name: [param: string, description: string][]
246+
}
247+
): void;
248+
~~~
249+
250+
You should pass the following parameters to the method:
251+
252+
<table>
253+
<tbody>
254+
<tr>
255+
<td><b>Parameter</b></td>
256+
<td align="center"><b>Description</b></td>
257+
</tr>
258+
<tr>
259+
<td>"formulas"</td>
260+
<td>(*required*) the name of the locale for formulas</td>
261+
</tr>
262+
<tr>
263+
<td>locale</td>
264+
<td>(*required*) the locale object that contains formulas' descriptions as <i>key:value</i> pairs, where:<ul><li>the <b>key</b> is the name of the function</li><li>the <b>value</b> is an array of parameters the function takes. Each parameter of the function is an array of two elements, where:<ul><li>the first element is the name of the parameter</li><li>the second element is the description of the parameter</li></ul></li></ul></td>
265+
</tr>
266+
</tbody>
267+
</table>
268+
269+
Check the example below:
270+
271+
~~~jsx
272+
const de = {
273+
AVERAGE: [
274+
["Zahl1", "Erforderlich. Eine Zahl oder Zellreferenz, die sich auf numerische Werte bezieht."],
275+
["Zahl2", "Optional. Eine Zahl oder Zellreferenz, die auf numerische Werte verweist."]
276+
],
277+
// other formulas' descriptions
278+
};
279+
280+
dhx.i18n.setLocale("formulas", de);
281+
~~~
282+
283+
## Example
284+
285+
In this snippet you can see how to switch between locales:
154286

155287
<iframe src="https://snippet.dhtmlx.com/yn5hyyim?mode=js" frameborder="0" class="snippet_iframe" width="100%" height="500"></iframe>

0 commit comments

Comments
 (0)