From 3b47bfe3d9d256710a9a01bc658f1a4202d4eac6 Mon Sep 17 00:00:00 2001 From: izulin Date: Sat, 8 Aug 2020 22:16:45 +0200 Subject: [PATCH 1/2] E() function is reduntant and creates name collision. --- docs/guide/built-in-functions.md | 1 - src/i18n/languages/csCZ.ts | 1 - src/i18n/languages/daDK.ts | 1 - src/i18n/languages/deDE.ts | 1 - src/i18n/languages/enGB.ts | 1 - src/i18n/languages/esES.ts | 1 - src/i18n/languages/fiFI.ts | 1 - src/i18n/languages/frFR.ts | 1 - src/i18n/languages/huHU.ts | 1 - src/i18n/languages/itIT.ts | 1 - src/i18n/languages/nbNO.ts | 1 - src/i18n/languages/nlNL.ts | 1 - src/i18n/languages/plPL.ts | 1 - src/i18n/languages/ptPT.ts | 1 - src/i18n/languages/ruRU.ts | 1 - src/i18n/languages/svSE.ts | 1 - src/i18n/languages/trTR.ts | 1 - src/interpreter/plugin/MathConstantsPlugin.ts | 11 ----------- test/i18n.spec.ts | 10 ++++++++++ test/interpreter/function-e.spec.ts | 19 ------------------- 20 files changed, 10 insertions(+), 47 deletions(-) delete mode 100644 test/interpreter/function-e.spec.ts diff --git a/docs/guide/built-in-functions.md b/docs/guide/built-in-functions.md index 437ee8bf43..6e751c8a58 100644 --- a/docs/guide/built-in-functions.md +++ b/docs/guide/built-in-functions.md @@ -131,7 +131,6 @@ lets you design your own [custom functions](custom-functions). | COUNTUNIQUE | Math and trigonometry | Counts the number of unique values in a list of specified values and ranges. | COUNTUNIQUE(Value1, [Value2, ...]) | | DECIMAL | Math and trigonometry | Converts text with characters from a number system to a positive integer in the base radix given. | DECIMAL("Text"; Radix) | | DEGREES | Math and trigonometry | Converts radians into degrees. | DEGREES(Number) | -| E | Math and trigonometry | Returns 2.718281828459..., the value of the mathematical constant E to as many decimal places as set in configuration | E() | | EVEN | Math and trigonometry | Rounds a positive number up to the next even integer and a negative number down to the next even integer. | EVEN(Number) | | EXP | Math and trigonometry | Returns e raised to the power of a number. | EXP(Number) | | INT | Math and trigonometry | Rounds a number down to the nearest integer. | INT(Number) | diff --git a/src/i18n/languages/csCZ.ts b/src/i18n/languages/csCZ.ts index 68f8a25812..13dbefdb88 100644 --- a/src/i18n/languages/csCZ.ts +++ b/src/i18n/languages/csCZ.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DECIMAL', DEGREES: 'DEGREES', DELTA: 'DELTA', - E: 'E', EOMONTH: 'EOMONTH', ERF: 'ERF', ERFC: 'ERFC', diff --git a/src/i18n/languages/daDK.ts b/src/i18n/languages/daDK.ts index d1d824b767..ab70dd3881 100644 --- a/src/i18n/languages/daDK.ts +++ b/src/i18n/languages/daDK.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DECIMAL', DEGREES: 'GRADER', DELTA: 'DELTA', - E: 'E', EOMONTH: 'SLUT.PÅ.MÅNED', ERF: 'FEJLFUNK', ERFC: 'FEJLFUNK.KOMP', diff --git a/src/i18n/languages/deDE.ts b/src/i18n/languages/deDE.ts index 3de8ef765d..15a566dd71 100644 --- a/src/i18n/languages/deDE.ts +++ b/src/i18n/languages/deDE.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DEZIMAL', DEGREES: 'GRAD', DELTA: 'DELTA', - E: 'E', EOMONTH: 'MONATSENDE', ERF: 'GAUSSFEHLER', ERFC: 'GAUSSFKOMPL', diff --git a/src/i18n/languages/enGB.ts b/src/i18n/languages/enGB.ts index 4765c7b808..a392d19ba8 100644 --- a/src/i18n/languages/enGB.ts +++ b/src/i18n/languages/enGB.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DECIMAL', DEGREES: 'DEGREES', DELTA: 'DELTA', - E: 'E', EOMONTH: 'EOMONTH', ERF: 'ERF', ERFC: 'ERFC', diff --git a/src/i18n/languages/esES.ts b/src/i18n/languages/esES.ts index 0f48e7b96e..0c236cf43e 100644 --- a/src/i18n/languages/esES.ts +++ b/src/i18n/languages/esES.ts @@ -61,7 +61,6 @@ export const dictionary: RawTranslationPackage = { DECIMAL: 'CONV.DECIMAL', DEGREES: 'GRADOS', DELTA: 'DELTA', - E: 'E', EOMONTH: 'FIN.MES', ERF: 'FUN.ERROR', ERFC: 'FUN.ERROR.COMPL', diff --git a/src/i18n/languages/fiFI.ts b/src/i18n/languages/fiFI.ts index dcb54d139a..efab195b1f 100644 --- a/src/i18n/languages/fiFI.ts +++ b/src/i18n/languages/fiFI.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DESIMAALI', DEGREES: 'ASTEET', DELTA: 'SAMA.ARVO', - E: 'E', EOMONTH: 'KUUKAUSI.LOPPU', ERF: 'VIRHEFUNKTIO', ERFC: 'VIRHEFUNKTIO.KOMPLEMENTTI', diff --git a/src/i18n/languages/frFR.ts b/src/i18n/languages/frFR.ts index 7993c4a2e4..e92deadb12 100644 --- a/src/i18n/languages/frFR.ts +++ b/src/i18n/languages/frFR.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DECIMAL', DEGREES: 'DEGRES', DELTA: 'DELTA', - E: 'E', EOMONTH: 'FIN.MOIS', ERF: 'ERF', ERFC: 'ERFC', diff --git a/src/i18n/languages/huHU.ts b/src/i18n/languages/huHU.ts index 9cac059907..0df4aaa9e5 100644 --- a/src/i18n/languages/huHU.ts +++ b/src/i18n/languages/huHU.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'TIZEDES', DEGREES: 'FOK', DELTA: 'DELTA', - E: 'E', EOMONTH: 'HÓNAP.UTOLSÓ.NAP', ERF: 'HIBAF', ERFC: 'HIBAF.KOMPLEMENTER', diff --git a/src/i18n/languages/itIT.ts b/src/i18n/languages/itIT.ts index c5b3581b66..5a725b0e78 100644 --- a/src/i18n/languages/itIT.ts +++ b/src/i18n/languages/itIT.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DECIMALE', DEGREES: 'GRADI', DELTA: 'DELTA', - E: 'E', EOMONTH: 'FINE.MESE', ERF: 'FUNZ.ERRORE', ERFC: 'FUNZ.ERRORE.COMP', diff --git a/src/i18n/languages/nbNO.ts b/src/i18n/languages/nbNO.ts index 17def8c862..d461ce9bc6 100644 --- a/src/i18n/languages/nbNO.ts +++ b/src/i18n/languages/nbNO.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DESIMAL', DEGREES: 'GRADER', DELTA: 'DELTA', - E: 'E', EOMONTH: 'MÅNEDSSLUTT', ERF: 'FEILF', ERFC: 'FEILFK', diff --git a/src/i18n/languages/nlNL.ts b/src/i18n/languages/nlNL.ts index 4011ec59a3..c5296c8e46 100644 --- a/src/i18n/languages/nlNL.ts +++ b/src/i18n/languages/nlNL.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DECIMAAL', DEGREES: 'GRADEN', DELTA: 'DELTA', - E: 'E', EOMONTH: 'LAATSTE.DAG', ERF: 'FOUTFUNCTIE', ERFC: 'FOUT.COMPLEMENT', diff --git a/src/i18n/languages/plPL.ts b/src/i18n/languages/plPL.ts index ca2620e801..4df67279f0 100644 --- a/src/i18n/languages/plPL.ts +++ b/src/i18n/languages/plPL.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DZIESIĘTNA', DEGREES: 'STOPNIE', DELTA: 'DELTA', - E: 'E', EOMONTH: 'NR.SER.OST.DN.MIEŚ', ERF: 'FUNKCJA.BŁ', ERFC: 'KOMP.FUNKCJA.BŁ', diff --git a/src/i18n/languages/ptPT.ts b/src/i18n/languages/ptPT.ts index 14bcf08282..8ba75f59f8 100644 --- a/src/i18n/languages/ptPT.ts +++ b/src/i18n/languages/ptPT.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DECIMAL', DEGREES: 'GRAUS', DELTA: 'DELTA', - E: 'E', EOMONTH: 'FIMMÊS', ERF: 'FUNERRO', ERFC: 'FUNERROCOMPL', diff --git a/src/i18n/languages/ruRU.ts b/src/i18n/languages/ruRU.ts index 9fc40077f7..e6ea9e05f9 100644 --- a/src/i18n/languages/ruRU.ts +++ b/src/i18n/languages/ruRU.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'ДЕС', DEGREES: 'ГРАДУСЫ', DELTA: 'ДЕЛЬТА', - E: 'E', EOMONTH: 'КОНМЕСЯЦА', ERF: 'ФОШ', ERFC: 'ДФОШ', diff --git a/src/i18n/languages/svSE.ts b/src/i18n/languages/svSE.ts index 0772955356..f970f2620e 100644 --- a/src/i18n/languages/svSE.ts +++ b/src/i18n/languages/svSE.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'DECIMAL', DEGREES: 'GRADER', DELTA: 'DELTA', - E: 'E', EOMONTH: 'SLUTMÅNAD', ERF: 'FELF', ERFC: 'FELFK', diff --git a/src/i18n/languages/trTR.ts b/src/i18n/languages/trTR.ts index 52ba9e478b..a6c31a2c3e 100644 --- a/src/i18n/languages/trTR.ts +++ b/src/i18n/languages/trTR.ts @@ -61,7 +61,6 @@ const dictionary: RawTranslationPackage = { DECIMAL: 'ONDALIK', DEGREES: 'DERECE', DELTA: 'DELTA', - E: 'E', EOMONTH: 'SERİAY', ERF: 'HATAİŞLEV', ERFC: 'TÜMHATAİŞLEV', diff --git a/src/interpreter/plugin/MathConstantsPlugin.ts b/src/interpreter/plugin/MathConstantsPlugin.ts index b3cd67e41a..b63e19e6b2 100644 --- a/src/interpreter/plugin/MathConstantsPlugin.ts +++ b/src/interpreter/plugin/MathConstantsPlugin.ts @@ -8,7 +8,6 @@ import {ProcedureAst} from '../../parser' import {FunctionPlugin} from './FunctionPlugin' const PI = parseFloat(Math.PI.toFixed(14)) -const E = parseFloat(Math.E.toFixed(14)) export class MathConstantsPlugin extends FunctionPlugin { public static implementedFunctions = { @@ -16,10 +15,6 @@ export class MathConstantsPlugin extends FunctionPlugin { method: 'pi', parameters: [], }, - 'E': { - method: 'e', - parameters: [], - }, } public pi(ast: ProcedureAst, formulaAddress: SimpleCellAddress): InternalScalarValue { @@ -27,10 +22,4 @@ export class MathConstantsPlugin extends FunctionPlugin { () => PI ) } - - public e(ast: ProcedureAst, formulaAddress: SimpleCellAddress): InternalScalarValue { - return this.runFunction(ast.args, formulaAddress, this.metadata('E'), - () => E - ) - } } diff --git a/test/i18n.spec.ts b/test/i18n.spec.ts index 75aa14e2c2..1a34db094e 100644 --- a/test/i18n.spec.ts +++ b/test/i18n.spec.ts @@ -88,6 +88,16 @@ describe('i18n', () => { }) }) + it('functions should have unique names in a single language', () => { + allLanguages.forEach(lang => { + const names = Object.values(lang.functions) + names.sort() + for(let i=0;i { // eslint-disable-next-line // @ts-ignore diff --git a/test/interpreter/function-e.spec.ts b/test/interpreter/function-e.spec.ts deleted file mode 100644 index 8845c0d8f4..0000000000 --- a/test/interpreter/function-e.spec.ts +++ /dev/null @@ -1,19 +0,0 @@ -import {HyperFormula} from '../../src' -import {ErrorType} from '../../src/Cell' -import {adr, detailedError} from '../testUtils' - -describe('Function E', () => { - it('wrong number of arguments', () => { - const engine = HyperFormula.buildFromArray([['=E(1)']]) - - expect(engine.getCellValue(adr('A1'))).toEqual(detailedError(ErrorType.NA)) - }) - it('should return E with proper precision', () => { - const engine = HyperFormula.buildFromArray([ - ['=E()'], - ], { smartRounding : false}) - - expect(engine.getCellValue(adr('A1'))).toEqual(2.71828182845905) - }) -}) - From f15c67fab860a57d15a9da011d5250c19228b0d7 Mon Sep 17 00:00:00 2001 From: izulin Date: Sat, 8 Aug 2020 22:20:34 +0200 Subject: [PATCH 2/2] doc --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8ee239d30..c99ab1986c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed `moveCells` behaviour when moving part of a range. (#479) - Fixed `moveColumns`/`moveRows` inconsistent behaviour. (#479) - Fixed undo of `moveColumns`/`moveRows` operations. (#479) +- Fixed name-collision issue in translations. ## [0.1.3] - 2020-07-21