Skip to content

Commit

Permalink
[Lens] i18n tinymath help text (elastic#104205)
Browse files Browse the repository at this point in the history
* [Lens] i18n tinymath help text

* Fix i18n ids for remaining strings

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
Wylie Conlon and kibanamachine authored Jul 6, 2021
1 parent d20de12 commit df8f870
Showing 1 changed file with 75 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,20 @@ export const tinymathFunctions: Record<
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.addFunction.markdown', {
defaultMessage: `
Adds up two numbers.
Also works with + symbol
Example: Calculate the sum of two fields
${'`sum(price) + sum(tax)`'}
\`sum(price) + sum(tax)\`
Example: Offset count by a static value
${'`add(count(), 5)`'}
\`add(count(), 5)\`
`,
}),
},
subtract: {
positionalArguments: [
Expand All @@ -130,13 +132,15 @@ ${'`add(count(), 5)`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.subtractFunction.markdown', {
defaultMessage: `
Subtracts the first number from the second number.
Also works with ${'`-`'} symbol
Also works with \`-\` symbol
Example: Calculate the range of a field
${'`subtract(max(bytes), min(bytes))`'}
\`subtract(max(bytes), min(bytes))\`
`,
}),
},
multiply: {
positionalArguments: [
Expand All @@ -149,16 +153,18 @@ ${'`subtract(max(bytes), min(bytes))`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.multiplyFunction.markdown', {
defaultMessage: `
Multiplies two numbers.
Also works with ${'`*`'} symbol.
Also works with \`*\` symbol.
Example: Calculate price after current tax rate
${'`sum(bytes) * last_value(tax_rate)`'}
\`sum(bytes) * last_value(tax_rate)\`
Example: Calculate price after constant tax rate
${'`multiply(sum(price), 1.2)`'}
\`multiply(sum(price), 1.2)\`
`,
}),
},
divide: {
positionalArguments: [
Expand All @@ -171,15 +177,17 @@ ${'`multiply(sum(price), 1.2)`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.divideFunction.markdown', {
defaultMessage: `
Divides the first number by the second number.
Also works with ${'`/`'} symbol
Also works with \`/\` symbol
Example: Calculate profit margin
${'`sum(profit) / sum(revenue)`'}
\`sum(profit) / sum(revenue)\`
Example: ${'`divide(sum(bytes), 2)`'}
Example: \`divide(sum(bytes), 2)\`
`,
}),
},
abs: {
positionalArguments: [
Expand All @@ -188,11 +196,13 @@ Example: ${'`divide(sum(bytes), 2)`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.absFunction.markdown', {
defaultMessage: `
Calculates absolute value. A negative value is multiplied by -1, a positive value stays the same.
Example: Calculate average distance to sea level ${'`abs(average(altitude))`'}
Example: Calculate average distance to sea level \`abs(average(altitude))\`
`,
}),
},
cbrt: {
positionalArguments: [
Expand All @@ -201,12 +211,14 @@ Example: Calculate average distance to sea level ${'`abs(average(altitude))`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.cbrtFunction.markdown', {
defaultMessage: `
Cube root of value.
Example: Calculate side length from volume
${'`cbrt(last_value(volume))`'}
\`cbrt(last_value(volume))\`
`,
}),
},
ceil: {
positionalArguments: [
Expand All @@ -215,13 +227,14 @@ ${'`cbrt(last_value(volume))`'}
type: getTypeI18n('number'),
},
],
// signature: 'ceil(value: number)',
help: `
help: i18n.translate('xpack.lens.formula.ceilFunction.markdown', {
defaultMessage: `
Ceiling of value, rounds up.
Example: Round up price to the next dollar
${'`ceil(sum(price))`'}
\`ceil(sum(price))\`
`,
}),
},
clamp: {
positionalArguments: [
Expand All @@ -238,8 +251,8 @@ ${'`ceil(sum(price))`'}
type: getTypeI18n('number'),
},
],
// signature: 'clamp(value: number, minimum: number, maximum: number)',
help: `
help: i18n.translate('xpack.lens.formula.clampFunction.markdown', {
defaultMessage: `
Limits the value from a minimum to maximum.
Example: Make sure to catch outliers
Expand All @@ -251,6 +264,7 @@ clamp(
)
\`\`\`
`,
}),
},
cube: {
positionalArguments: [
Expand All @@ -259,12 +273,14 @@ clamp(
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.cubeFunction.markdown', {
defaultMessage: `
Calculates the cube of a number.
Example: Calculate volume from side length
${'`cube(last_value(length))`'}
\`cube(last_value(length))\`
`,
}),
},
exp: {
positionalArguments: [
Expand All @@ -273,13 +289,15 @@ ${'`cube(last_value(length))`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.expFunction.markdown', {
defaultMessage: `
Raises *e* to the nth power.
Example: Calculate the natural exponential function
${'`exp(last_value(duration))`'}
\`exp(last_value(duration))\`
`,
}),
},
fix: {
positionalArguments: [
Expand All @@ -288,12 +306,14 @@ ${'`exp(last_value(duration))`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.fixFunction.markdown', {
defaultMessage: `
For positive values, takes the floor. For negative values, takes the ceiling.
Example: Rounding towards zero
${'`fix(sum(profit))`'}
\`fix(sum(profit))\`
`,
}),
},
floor: {
positionalArguments: [
Expand All @@ -302,12 +322,14 @@ ${'`fix(sum(profit))`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.floorFunction.markdown', {
defaultMessage: `
Round down to nearest integer value
Example: Round down a price
${'`floor(sum(price))`'}
\`floor(sum(price))\`
`,
}),
},
log: {
positionalArguments: [
Expand All @@ -322,7 +344,8 @@ ${'`floor(sum(price))`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.logFunction.markdown', {
defaultMessage: `
Logarithm with optional base. The natural base *e* is used as default.
Example: Calculate number of bits required to store values
Expand All @@ -331,17 +354,8 @@ log(sum(bytes))
log(sum(bytes), 2)
\`\`\`
`,
}),
},
// TODO: check if this is valid for Tinymath
// log10: {
// positionalArguments: [
// { name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), type: getTypeI18n('number') },
// ],
// help: `
// Base 10 logarithm.
// Example: ${'`log10(sum(bytes))`'}
// `,
// },
mod: {
positionalArguments: [
{
Expand All @@ -353,12 +367,14 @@ log(sum(bytes), 2)
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.modFunction.markdown', {
defaultMessage: `
Remainder after dividing the function by a number
Example: Calculate last three digits of a value
${'`mod(sum(price), 1000)`'}
\`mod(sum(price), 1000)\`
`,
}),
},
pow: {
positionalArguments: [
Expand All @@ -371,12 +387,14 @@ ${'`mod(sum(price), 1000)`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.powFunction.markdown', {
defaultMessage: `
Raises the value to a certain power. The second argument is required
Example: Calculate volume based on side length
${'`pow(last_value(length), 3)`'}
\`pow(last_value(length), 3)\`
`,
}),
},
round: {
positionalArguments: [
Expand All @@ -391,7 +409,8 @@ ${'`pow(last_value(length), 3)`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.roundFunction.markdown', {
defaultMessage: `
Rounds to a specific number of decimal places, default of 0
Examples: Round to the cent
Expand All @@ -400,6 +419,7 @@ round(sum(bytes))
round(sum(bytes), 2)
\`\`\`
`,
}),
},
sqrt: {
positionalArguments: [
Expand All @@ -408,12 +428,14 @@ round(sum(bytes), 2)
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.sqrtFunction.markdown', {
defaultMessage: `
Square root of a positive value only
Example: Calculate side length based on area
${'`sqrt(last_value(area))`'}
\`sqrt(last_value(area))\`
`,
}),
},
square: {
positionalArguments: [
Expand All @@ -422,12 +444,14 @@ ${'`sqrt(last_value(area))`'}
type: getTypeI18n('number'),
},
],
help: `
help: i18n.translate('xpack.lens.formula.squareFunction.markdown', {
defaultMessage: `
Raise the value to the 2nd power
Example: Calculate area based on side length
${'`square(last_value(length))`'}
\`square(last_value(length))\`
`,
}),
},
};

Expand Down

0 comments on commit df8f870

Please sign in to comment.