From 02012d6409b7c6cab0c8e05112ad614e0a76ffcc Mon Sep 17 00:00:00 2001 From: Eric Boot Date: Mon, 27 Jan 2025 10:52:46 +0100 Subject: [PATCH 1/9] fix: allow gherkin keywords as supported by cucumber --- lib/mocha/gherkin.js | 6 +++--- test/data/sandbox/i18n/codecept.bdd.nl.js | 19 ++++++++++++++++++ .../sandbox/i18n/features/examples.nl.feature | 16 +++++++++++++++ .../features/step_definitions/my_steps.nl.js | 17 ++++++++++++++++ test/runner/bdd_test.js | 20 +++++++++++++++++++ 5 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 test/data/sandbox/i18n/codecept.bdd.nl.js create mode 100644 test/data/sandbox/i18n/features/examples.nl.feature create mode 100644 test/data/sandbox/i18n/features/step_definitions/my_steps.nl.js diff --git a/lib/mocha/gherkin.js b/lib/mocha/gherkin.js index 2e4d040fe..7b17ea3a2 100644 --- a/lib/mocha/gherkin.js +++ b/lib/mocha/gherkin.js @@ -107,7 +107,7 @@ module.exports = (text, file) => { ) continue } - if (child.scenario && (currentLanguage ? child.scenario.keyword === currentLanguage.contexts.ScenarioOutline : child.scenario.keyword === 'Scenario Outline')) { + if (child.scenario && (currentLanguage ? currentLanguage.scenarioOutline.includes(child.scenario.keyword) : child.scenario.keyword === 'Scenario Outline')) { for (const examples of child.scenario.examples) { const fields = examples.tableHeader.cells.map(c => c.value) for (const example of examples.tableBody) { @@ -185,7 +185,7 @@ function addExampleInTable(exampleSteps, placeholders) { } function getTranslation(language) { - const translations = Object.keys(require('../../translations')) + const translations = Object.keys(require('@cucumber/gherkin/src/gherkin-languages.json')) for (const availableTranslation of translations) { if (!language) { @@ -193,7 +193,7 @@ function getTranslation(language) { } if (availableTranslation.includes(language)) { - return require('../../translations')[availableTranslation] + return require('@cucumber/gherkin/src/gherkin-languages.json')[availableTranslation] } } } diff --git a/test/data/sandbox/i18n/codecept.bdd.nl.js b/test/data/sandbox/i18n/codecept.bdd.nl.js new file mode 100644 index 000000000..cd2f475bf --- /dev/null +++ b/test/data/sandbox/i18n/codecept.bdd.nl.js @@ -0,0 +1,19 @@ +exports.config = { + tests: './*_no_test.js', + timeout: 10000, + output: '../output', + helpers: { + BDD: { + require: '../support/bdd_helper.js', + }, + }, + gherkin: { + features: './features/examples.nl.feature', + steps: ['./features/step_definitions/my_steps.nl.js'], + }, + include: {}, + bootstrap: false, + mocha: {}, + name: 'sandbox', + translation: 'nl-NL', +} diff --git a/test/data/sandbox/i18n/features/examples.nl.feature b/test/data/sandbox/i18n/features/examples.nl.feature new file mode 100644 index 000000000..84bf33ded --- /dev/null +++ b/test/data/sandbox/i18n/features/examples.nl.feature @@ -0,0 +1,16 @@ +#language: nl +Functionaliteit: Checkout proces + Om producten te kopen + Als klant + Moet ik in staat zijn om meerdere producten te kopen + + @i18n + Abstract Scenario: korting bestellen + Gegeven ik heb een product met een prijs van $ in mijn winkelwagen + En de korting voor bestellingen van meer dan $20 is 10 % + Wanneer ik naar de kassa ga + Dan zou ik de totaalprijs van "" $ moeten zien + + Voorbeelden: + | price | total | + | 10 | 10.0 | diff --git a/test/data/sandbox/i18n/features/step_definitions/my_steps.nl.js b/test/data/sandbox/i18n/features/step_definitions/my_steps.nl.js new file mode 100644 index 000000000..52537f762 --- /dev/null +++ b/test/data/sandbox/i18n/features/step_definitions/my_steps.nl.js @@ -0,0 +1,17 @@ +const I = actor() + +Given('ik heb een product met een prijs van {int}$ in mijn winkelwagen', price => { + I.addItem(parseInt(price, 10)) +}) + +Given('de korting voor bestellingen van meer dan ${int} is {int} %', (maxPrice, discount) => { + I.haveDiscountForPrice(maxPrice, discount) +}) + +When('ik naar de kassa ga', () => { + I.checkout() +}) + +Then('zou ik de totaalprijs van "{float}" $ moeten zien', price => { + I.seeSum(price) +}) diff --git a/test/runner/bdd_test.js b/test/runner/bdd_test.js index e959a31b5..23ca4c25a 100644 --- a/test/runner/bdd_test.js +++ b/test/runner/bdd_test.js @@ -353,5 +353,25 @@ When(/^I define a step with a \\( paren and a "(.*?)" string$/, () => { done() }) }) + + it('should run feature files in NL', done => { + exec(config_run_config('codecept.bdd.nl.js') + ' --steps --grep "@i18n"', (err, stdout, stderr) => { + console.log(stdout) + stdout.should.include('On Gegeven: ik heb een product met een prijs van 10$ in mijn winkelwagen') + stdout.should.include('On En: de korting voor bestellingen van meer dan $20 is 10 %') + stdout.should.include('On Wanneer: ik naar de kassa ga') + stdout.should.include('On Dan: zou ik de totaalprijs van "10.0" $ moeten zien') + stdout.should.include('On Gegeven: ik heb een product met een prijs van 10$ in mijn winkelwagen') + stdout.should.include('I add item 10') + stdout.should.include('On En: de korting voor bestellingen van meer dan $20 is 10 %') + stdout.should.include('I have discount for price 20, 10') + stdout.should.include('On Wanneer: ik naar de kassa ga') + stdout.should.include('I checkout') + stdout.should.include('On Dan: zou ik de totaalprijs van "10.0" $ moeten zien') + stdout.should.include('I see sum 10') + assert(!err) + done() + }) + }) }) }) From 72fc02e7f072682406c2f340a560a5b84b3d6cd6 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 27 Jan 2025 11:45:16 +0100 Subject: [PATCH 2/9] support NL --- lib/mocha/gherkin.js | 4 +-- translations/de-DE.js | 9 +++-- translations/fr-FR.js | 9 +++-- translations/index.js | 1 + translations/it-IT.js | 9 +++-- translations/ja-JP.js | 9 +++-- translations/nl-NL.js | 78 +++++++++++++++++++++++++++++++++++++++++++ translations/pl-PL.js | 9 +++-- translations/pt-BR.js | 9 +++-- translations/ru-RU.js | 9 +++-- translations/zh-CN.js | 9 +++-- translations/zh-TW.js | 9 +++-- 12 files changed, 135 insertions(+), 29 deletions(-) create mode 100644 translations/nl-NL.js diff --git a/lib/mocha/gherkin.js b/lib/mocha/gherkin.js index 7b17ea3a2..45133f1ab 100644 --- a/lib/mocha/gherkin.js +++ b/lib/mocha/gherkin.js @@ -185,7 +185,7 @@ function addExampleInTable(exampleSteps, placeholders) { } function getTranslation(language) { - const translations = Object.keys(require('@cucumber/gherkin/src/gherkin-languages.json')) + const translations = Object.keys(require('../../translations')) for (const availableTranslation of translations) { if (!language) { @@ -193,7 +193,7 @@ function getTranslation(language) { } if (availableTranslation.includes(language)) { - return require('@cucumber/gherkin/src/gherkin-languages.json')[availableTranslation] + return require('../../translations')[availableTranslation] } } } diff --git a/translations/de-DE.js b/translations/de-DE.js index 7a84c985d..60d2ab3bb 100644 --- a/translations/de-DE.js +++ b/translations/de-DE.js @@ -1,9 +1,12 @@ +const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const langCode = 'de' + module.exports = { I: 'Ich', contexts: { - Feature: 'Funktionalität', - Scenario: 'Szenario', - ScenarioOutline: 'Szenariogrundriss', + Feature: gherkinTranslations[langCode].feature[0], + Scenario: gherkinTranslations[langCode].scenario[0], + ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], }, actions: { amOutsideAngularApp: 'befinde_mich_außerhalb_der_angular_app', diff --git a/translations/fr-FR.js b/translations/fr-FR.js index de67a063f..ef5f34744 100644 --- a/translations/fr-FR.js +++ b/translations/fr-FR.js @@ -1,9 +1,12 @@ +const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const langCode = 'fr' + module.exports = { I: 'Je', contexts: { - Feature: 'Fonctionnalité', - Scenario: 'Scénario', - ScenarioOutline: 'Plan du scénario', + Feature: gherkinTranslations[langCode].feature[0], + Scenario: gherkinTranslations[langCode].scenario[0], + ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], Before: 'Avant', After: 'Après', BeforeSuite: 'AvantLaSuite', diff --git a/translations/index.js b/translations/index.js index 7767e717b..6e357e549 100644 --- a/translations/index.js +++ b/translations/index.js @@ -7,3 +7,4 @@ exports['pt-BR'] = require('./pt-BR') exports['ru-RU'] = require('./ru-RU') exports['zh-CN'] = require('./zh-CN') exports['zh-TW'] = require('./zh-TW') +exports['nl-NL'] = require('./nl-NL') diff --git a/translations/it-IT.js b/translations/it-IT.js index 2dd161467..23e121aee 100644 --- a/translations/it-IT.js +++ b/translations/it-IT.js @@ -1,9 +1,12 @@ +const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const langCode = 'it' + module.exports = { I: 'io', contexts: { - Feature: 'Caratteristica', - Scenario: 'lo_scenario', - ScenarioOutline: 'Schema dello scenario', + Feature: gherkinTranslations[langCode].feature[0], + Scenario: gherkinTranslations[langCode].scenario[0], + ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], Before: 'Prima', After: 'Dopo', BeforeSuite: 'Prima_della_suite', diff --git a/translations/ja-JP.js b/translations/ja-JP.js index acbcfca13..d164bfa7d 100644 --- a/translations/ja-JP.js +++ b/translations/ja-JP.js @@ -1,9 +1,12 @@ +const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const langCode = 'ja' + module.exports = { I: '私は', contexts: { - Feature: 'フィーチャ', - Scenario: 'シナリオ', - ScenarioOutline: 'シナリオアウトライン', + Feature: gherkinTranslations[langCode].feature[0], + Scenario: gherkinTranslations[langCode].scenario[0], + ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], }, actions: { amOutsideAngularApp: 'Angularの外に出る', diff --git a/translations/nl-NL.js b/translations/nl-NL.js new file mode 100644 index 000000000..9de2e20b0 --- /dev/null +++ b/translations/nl-NL.js @@ -0,0 +1,78 @@ +const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const langCode = 'nl' + +module.exports = { + I: 'Ik', + contexts: { + Feature: gherkinTranslations[langCode].feature[0], + Scenario: gherkinTranslations[langCode].scenario[0], + ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + }, + actions: { + amOutsideAngularApp: 'ben_buiten_angular_app', + amInsideAngularApp: 'ben_binnen_angular_app', + waitForElement: 'wacht_op_element', + waitForClickable: 'wacht_tot_klikbaar', + waitForVisible: 'wacht_tot_zichtbaar', + waitForEnabled: 'wacht_tot_ingeschakeld', + waitForInvisible: 'wacht_tot_onzichtbaar', + waitInUrl: 'wacht_in_url', + waitForText: 'wacht_op_tekst', + moveTo: 'beweeg_de_cursor_naar', + refresh: 'vernieuw_pagina', + refreshPage: 'vernieuw_pagina', + haveModule: 'heb_module', + resetModule: 'reset_module', + amOnPage: 'ben_op_pagina', + click: 'klik', + doubleClick: 'dubbelklik', + see: 'zie', + dontSee: 'zie_niet', + selectOption: 'selecteer_optie', + fillField: 'vul_veld_in', + pressKey: 'druk_op_toets', + triggerMouseEvent: 'trigger_een_muis_event', + attachFile: 'voeg_bestand_toe', + seeInField: 'zie_in_veld', + dontSeeInField: 'zie_niet_in_veld', + appendField: 'voeg_toe_aan_veld', + checkOption: 'vink_optie_aan', + seeCheckboxIsChecked: 'zie_dat_checkbox_aangevinkt_is', + dontSeeCheckboxIsChecked: 'zie_niet_dat_checkbox_aangevinkt_is', + grabTextFrom: 'haal_tekst_van', + grabValueFrom: 'haal_waarde_van', + grabAttributeFrom: 'haal_attribuut_van', + seeInTitle: 'zie_in_titel', + dontSeeInTitle: 'zie_niet_in_titel', + grabTitle: 'haal_titel_op', + seeElement: 'zie_element', + dontSeeElement: 'zie_niet_element', + seeInSource: 'zie_in_broncode', + dontSeeInSource: 'zie_niet_in_broncode', + executeScript: 'voer_script_uit', + executeAsyncScript: 'voer_asynchroon_script_uit', + seeInCurrentUrl: 'zie_in_huidige_url', + dontSeeInCurrentUrl: 'zie_niet_in_huidige_url', + seeCurrentUrlEquals: 'zie_dat_url_gelijk_is', + dontSeeCurrentUrlEquals: 'zie_dat_url_niet_gelijk_is', + saveScreenshot: 'sla_screenshot_op', + setCookie: 'stel_cookie_in', + clearCookie: 'verwijder_cookie', + seeCookie: 'zie_cookie', + dontSeeCookie: 'zie_niet_cookie', + grabCookie: 'haal_cookie_op', + resizeWindow: 'verander_venstergrootte', + wait: 'wacht', + haveHeader: 'gebruik_http_header', + clearField: 'wis_veld', + dontSeeElementInDOM: 'zie_niet_element_in_DOM', + moveCursorTo: 'beweeg_de_cursor_naar', + scrollTo: 'scroll_naar', + sendGetRequest: 'doe_een_get_verzoek', + sendPutRequest: 'doe_een_put_verzoek', + sendDeleteRequest: 'doe_een_delete_verzoek', + sendDeleteRequestWithPayload: 'doe_een_delete_verzoek_met_payload', + sendPostRequest: 'doe_een_post_verzoek', + switchTo: 'wissel_naar_iframe', + }, +} diff --git a/translations/pl-PL.js b/translations/pl-PL.js index 4e3c21813..ab911e93d 100644 --- a/translations/pl-PL.js +++ b/translations/pl-PL.js @@ -1,9 +1,12 @@ +const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const langCode = 'pl' + module.exports = { I: 'Ja', contexts: { - Feature: 'Funkcja', - Scenario: 'Scenariusz', - ScenarioOutline: 'Szablon scenariusza', + Feature: gherkinTranslations[langCode].feature[0], + Scenario: gherkinTranslations[langCode].scenario[0], + ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], }, actions: { amOutsideAngularApp: 'jestem_poza_aplikacją_angular', diff --git a/translations/pt-BR.js b/translations/pt-BR.js index 20b783994..8d0be125e 100644 --- a/translations/pt-BR.js +++ b/translations/pt-BR.js @@ -1,9 +1,12 @@ +const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const langCode = 'pt' + module.exports = { I: 'Eu', contexts: { - Feature: 'Funcionalidade', - Scenario: 'Cenário', - ScenarioOutline: 'Esquema do Cenário', + Feature: gherkinTranslations[langCode].feature[0], + Scenario: gherkinTranslations[langCode].scenario[0], + ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], Before: 'Antes', After: 'Depois', BeforeSuite: 'AntesDaSuite', diff --git a/translations/ru-RU.js b/translations/ru-RU.js index 21de4f9db..9b6e47819 100644 --- a/translations/ru-RU.js +++ b/translations/ru-RU.js @@ -1,9 +1,12 @@ +const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const langCode = 'ru' + module.exports = { I: 'Я', contexts: { - Feature: 'Цель', - Scenario: 'Сценарий', - ScenarioOutline: 'Структура сценария', + Feature: gherkinTranslations[langCode].feature[0], + Scenario: gherkinTranslations[langCode].scenario[0], + ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], Before: 'Начало', After: 'Конец', BeforeSuite: 'Перед_всем', diff --git a/translations/zh-CN.js b/translations/zh-CN.js index f2a4ae1af..3301d3713 100644 --- a/translations/zh-CN.js +++ b/translations/zh-CN.js @@ -1,9 +1,12 @@ +const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const langCode = 'zh-CN' + module.exports = { I: '我', contexts: { - Feature: '功能', - Scenario: '场景', - ScenarioOutline: '场景大纲', + Feature: gherkinTranslations[langCode].feature[0], + Scenario: gherkinTranslations[langCode].scenario[0], + ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], }, actions: { amOutsideAngularApp: '在Angular应用外', diff --git a/translations/zh-TW.js b/translations/zh-TW.js index 908dcb38f..2d9a25f3a 100644 --- a/translations/zh-TW.js +++ b/translations/zh-TW.js @@ -1,9 +1,12 @@ +const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const langCode = 'zh-TW' + module.exports = { I: '我', contexts: { - Feature: '功能', - Scenario: '場景', - ScenarioOutline: '場景大綱', + Feature: gherkinTranslations[langCode].feature[0], + Scenario: gherkinTranslations[langCode].scenario[0], + ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], }, actions: { amOutsideAngularApp: '在Angular應用外', From 053df6adae2cc7922df042ceb10ab997b181aacc Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 27 Jan 2025 11:46:52 +0100 Subject: [PATCH 3/9] support NL --- test/unit/container_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/container_test.js b/test/unit/container_test.js index 2e8e422b0..5ff3a13c1 100644 --- a/test/unit/container_test.js +++ b/test/unit/container_test.js @@ -46,7 +46,7 @@ describe('Container', () => { expect(container.translation()).to.be.instanceOf(Translation) expect(container.translation().loaded).to.be.true expect(container.translation().I).to.eql('io') - expect(container.translation().value('contexts').Feature).to.eql('Caratteristica') + expect(container.translation().value('contexts').Feature).to.eql('Funzionalità') }) it('should create French translation', () => { From 3f256e5794ba5a31acc72e17b562eabe6aed92fe Mon Sep 17 00:00:00 2001 From: Eric Boot Date: Mon, 27 Jan 2025 12:13:07 +0100 Subject: [PATCH 4/9] CR: NL fixes --- translations/nl-NL.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/translations/nl-NL.js b/translations/nl-NL.js index 9de2e20b0..d655f1970 100644 --- a/translations/nl-NL.js +++ b/translations/nl-NL.js @@ -39,14 +39,14 @@ module.exports = { checkOption: 'vink_optie_aan', seeCheckboxIsChecked: 'zie_dat_checkbox_aangevinkt_is', dontSeeCheckboxIsChecked: 'zie_niet_dat_checkbox_aangevinkt_is', - grabTextFrom: 'haal_tekst_van', - grabValueFrom: 'haal_waarde_van', - grabAttributeFrom: 'haal_attribuut_van', + grabTextFrom: 'pak_tekst_van', + grabValueFrom: 'pak_waarde_van', + grabAttributeFrom: 'pak_attribuut_van', seeInTitle: 'zie_in_titel', dontSeeInTitle: 'zie_niet_in_titel', - grabTitle: 'haal_titel_op', + grabTitle: 'pak_titel', seeElement: 'zie_element', - dontSeeElement: 'zie_niet_element', + dontSeeElement: 'zie_element_niet', seeInSource: 'zie_in_broncode', dontSeeInSource: 'zie_niet_in_broncode', executeScript: 'voer_script_uit', @@ -59,13 +59,13 @@ module.exports = { setCookie: 'stel_cookie_in', clearCookie: 'verwijder_cookie', seeCookie: 'zie_cookie', - dontSeeCookie: 'zie_niet_cookie', - grabCookie: 'haal_cookie_op', + dontSeeCookie: 'zie_cookie_niet', + grabCookie: 'pak_cookie', resizeWindow: 'verander_venstergrootte', wait: 'wacht', haveHeader: 'gebruik_http_header', clearField: 'wis_veld', - dontSeeElementInDOM: 'zie_niet_element_in_DOM', + dontSeeElementInDOM: 'zie_element_niet_in_DOM', moveCursorTo: 'beweeg_de_cursor_naar', scrollTo: 'scroll_naar', sendGetRequest: 'doe_een_get_verzoek', From 56be4b5d0168e54819222dff18b9ee07fba03975 Mon Sep 17 00:00:00 2001 From: Eric Boot Date: Mon, 27 Jan 2025 12:16:29 +0100 Subject: [PATCH 5/9] fix test --- test/runner/bdd_test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/runner/bdd_test.js b/test/runner/bdd_test.js index 23ca4c25a..ae0fb37fd 100644 --- a/test/runner/bdd_test.js +++ b/test/runner/bdd_test.js @@ -362,13 +362,13 @@ When(/^I define a step with a \\( paren and a "(.*?)" string$/, () => { stdout.should.include('On Wanneer: ik naar de kassa ga') stdout.should.include('On Dan: zou ik de totaalprijs van "10.0" $ moeten zien') stdout.should.include('On Gegeven: ik heb een product met een prijs van 10$ in mijn winkelwagen') - stdout.should.include('I add item 10') + stdout.should.include('Ik add item 10') stdout.should.include('On En: de korting voor bestellingen van meer dan $20 is 10 %') - stdout.should.include('I have discount for price 20, 10') + stdout.should.include('Ik have discount for price 20, 10') stdout.should.include('On Wanneer: ik naar de kassa ga') - stdout.should.include('I checkout') + stdout.should.include('Ik checkout') stdout.should.include('On Dan: zou ik de totaalprijs van "10.0" $ moeten zien') - stdout.should.include('I see sum 10') + stdout.should.include('Ik see sum 10') assert(!err) done() }) From c66e058edd2a54170b6b6bd8755afb1077e0ef89 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 27 Jan 2025 13:31:14 +0100 Subject: [PATCH 6/9] fix: failed UTs --- lib/mocha/gherkin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mocha/gherkin.js b/lib/mocha/gherkin.js index 45133f1ab..bcb3e63d8 100644 --- a/lib/mocha/gherkin.js +++ b/lib/mocha/gherkin.js @@ -107,7 +107,7 @@ module.exports = (text, file) => { ) continue } - if (child.scenario && (currentLanguage ? currentLanguage.scenarioOutline.includes(child.scenario.keyword) : child.scenario.keyword === 'Scenario Outline')) { + if (child.scenario && (currentLanguage ? currentLanguage.contexts.ScenarioOutline.includes(child.scenario.keyword) : child.scenario.keyword === 'Scenario Outline')) { for (const examples of child.scenario.examples) { const fields = examples.tableHeader.cells.map(c => c.value) for (const example of examples.tableBody) { From 8048b19a4f47fc544e05c3e8c16aac151acfc21f Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 27 Jan 2025 14:04:11 +0100 Subject: [PATCH 7/9] some improvements --- translations/de-DE.js | 10 +++++----- translations/fr-FR.js | 6 ++---- translations/it-IT.js | 6 ++---- translations/ja-JP.js | 6 ++---- translations/nl-NL.js | 6 ++---- translations/pl-PL.js | 6 ++---- translations/pt-BR.js | 6 ++---- translations/ru-RU.js | 6 ++---- translations/utils.js | 9 +++++++++ translations/zh-CN.js | 6 ++---- translations/zh-TW.js | 6 ++---- 11 files changed, 32 insertions(+), 41 deletions(-) create mode 100644 translations/utils.js diff --git a/translations/de-DE.js b/translations/de-DE.js index 60d2ab3bb..8653c36c4 100644 --- a/translations/de-DE.js +++ b/translations/de-DE.js @@ -1,12 +1,10 @@ -const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const { gherkinTranslations } = require('./utils') const langCode = 'de' -module.exports = { +const deTranslations = { I: 'Ich', contexts: { - Feature: gherkinTranslations[langCode].feature[0], - Scenario: gherkinTranslations[langCode].scenario[0], - ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: 'befinde_mich_außerhalb_der_angular_app', @@ -76,3 +74,5 @@ module.exports = { switchTo: 'wechlse_in_iframe', }, } + +module.exports = deTranslations diff --git a/translations/fr-FR.js b/translations/fr-FR.js index ef5f34744..ba109ee59 100644 --- a/translations/fr-FR.js +++ b/translations/fr-FR.js @@ -1,12 +1,10 @@ -const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const { gherkinTranslations } = require('./utils') const langCode = 'fr' module.exports = { I: 'Je', contexts: { - Feature: gherkinTranslations[langCode].feature[0], - Scenario: gherkinTranslations[langCode].scenario[0], - ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + ...gherkinTranslations(langCode), Before: 'Avant', After: 'Après', BeforeSuite: 'AvantLaSuite', diff --git a/translations/it-IT.js b/translations/it-IT.js index 23e121aee..b79b973ba 100644 --- a/translations/it-IT.js +++ b/translations/it-IT.js @@ -1,12 +1,10 @@ -const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const { gherkinTranslations } = require('./utils') const langCode = 'it' module.exports = { I: 'io', contexts: { - Feature: gherkinTranslations[langCode].feature[0], - Scenario: gherkinTranslations[langCode].scenario[0], - ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + ...gherkinTranslations(langCode), Before: 'Prima', After: 'Dopo', BeforeSuite: 'Prima_della_suite', diff --git a/translations/ja-JP.js b/translations/ja-JP.js index d164bfa7d..b749070f5 100644 --- a/translations/ja-JP.js +++ b/translations/ja-JP.js @@ -1,12 +1,10 @@ -const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const { gherkinTranslations } = require('./utils') const langCode = 'ja' module.exports = { I: '私は', contexts: { - Feature: gherkinTranslations[langCode].feature[0], - Scenario: gherkinTranslations[langCode].scenario[0], - ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: 'Angularの外に出る', diff --git a/translations/nl-NL.js b/translations/nl-NL.js index d655f1970..b336508c2 100644 --- a/translations/nl-NL.js +++ b/translations/nl-NL.js @@ -1,12 +1,10 @@ -const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const { gherkinTranslations } = require('./utils') const langCode = 'nl' module.exports = { I: 'Ik', contexts: { - Feature: gherkinTranslations[langCode].feature[0], - Scenario: gherkinTranslations[langCode].scenario[0], - ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: 'ben_buiten_angular_app', diff --git a/translations/pl-PL.js b/translations/pl-PL.js index ab911e93d..467e73594 100644 --- a/translations/pl-PL.js +++ b/translations/pl-PL.js @@ -1,12 +1,10 @@ -const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const { gherkinTranslations } = require('./utils') const langCode = 'pl' module.exports = { I: 'Ja', contexts: { - Feature: gherkinTranslations[langCode].feature[0], - Scenario: gherkinTranslations[langCode].scenario[0], - ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: 'jestem_poza_aplikacją_angular', diff --git a/translations/pt-BR.js b/translations/pt-BR.js index 8d0be125e..9ac8ea674 100644 --- a/translations/pt-BR.js +++ b/translations/pt-BR.js @@ -1,12 +1,10 @@ -const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const { gherkinTranslations } = require('./utils') const langCode = 'pt' module.exports = { I: 'Eu', contexts: { - Feature: gherkinTranslations[langCode].feature[0], - Scenario: gherkinTranslations[langCode].scenario[0], - ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + ...gherkinTranslations(langCode), Before: 'Antes', After: 'Depois', BeforeSuite: 'AntesDaSuite', diff --git a/translations/ru-RU.js b/translations/ru-RU.js index 9b6e47819..dd7892cbb 100644 --- a/translations/ru-RU.js +++ b/translations/ru-RU.js @@ -1,12 +1,10 @@ -const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const { gherkinTranslations } = require('./utils') const langCode = 'ru' module.exports = { I: 'Я', contexts: { - Feature: gherkinTranslations[langCode].feature[0], - Scenario: gherkinTranslations[langCode].scenario[0], - ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + ...gherkinTranslations(langCode), Before: 'Начало', After: 'Конец', BeforeSuite: 'Перед_всем', diff --git a/translations/utils.js b/translations/utils.js new file mode 100644 index 000000000..45d42dba8 --- /dev/null +++ b/translations/utils.js @@ -0,0 +1,9 @@ +module.exports.gherkinTranslations = function (langCode) { + const gherkinLanguages = require('@cucumber/gherkin/src/gherkin-languages.json') + const { feature, scenario, scenarioOutline } = gherkinLanguages[langCode] + return { + Feature: feature[0], + Scenario: scenario[0], + ScenarioOutline: scenarioOutline[0], + } +} diff --git a/translations/zh-CN.js b/translations/zh-CN.js index 3301d3713..fe6aa40e1 100644 --- a/translations/zh-CN.js +++ b/translations/zh-CN.js @@ -1,12 +1,10 @@ -const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const { gherkinTranslations } = require('./utils') const langCode = 'zh-CN' module.exports = { I: '我', contexts: { - Feature: gherkinTranslations[langCode].feature[0], - Scenario: gherkinTranslations[langCode].scenario[0], - ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: '在Angular应用外', diff --git a/translations/zh-TW.js b/translations/zh-TW.js index 2d9a25f3a..a8233211d 100644 --- a/translations/zh-TW.js +++ b/translations/zh-TW.js @@ -1,12 +1,10 @@ -const gherkinTranslations = require('@cucumber/gherkin/src/gherkin-languages.json') +const { gherkinTranslations } = require('./utils') const langCode = 'zh-TW' module.exports = { I: '我', contexts: { - Feature: gherkinTranslations[langCode].feature[0], - Scenario: gherkinTranslations[langCode].scenario[0], - ScenarioOutline: gherkinTranslations[langCode].scenarioOutline[0], + ...gherkinTranslations(langCode), }, actions: { amOutsideAngularApp: '在Angular應用外', From e2af7c98128b0dcc8d8b64ede40ad42fc55598f4 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 27 Jan 2025 14:04:40 +0100 Subject: [PATCH 8/9] some improvements --- translations/de-DE.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/translations/de-DE.js b/translations/de-DE.js index 8653c36c4..d1767d068 100644 --- a/translations/de-DE.js +++ b/translations/de-DE.js @@ -1,7 +1,7 @@ const { gherkinTranslations } = require('./utils') const langCode = 'de' -const deTranslations = { +module.exports = { I: 'Ich', contexts: { ...gherkinTranslations(langCode), @@ -74,5 +74,3 @@ const deTranslations = { switchTo: 'wechlse_in_iframe', }, } - -module.exports = deTranslations From 637e92b0af43b464347b0a7701ae3fb977b5a314 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 27 Jan 2025 14:20:24 +0100 Subject: [PATCH 9/9] some improvements --- .../configs/translation/translation_test.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/data/sandbox/configs/translation/translation_test.js b/test/data/sandbox/configs/translation/translation_test.js index f2571c2cc..933d5fc68 100644 --- a/test/data/sandbox/configs/translation/translation_test.js +++ b/test/data/sandbox/configs/translation/translation_test.js @@ -1,17 +1,17 @@ -Caratteristica('DevTo'); +Funzionalità('DevTo') Prima(() => { - console.log('Before'); -}); + console.log('Before') +}) -lo_scenario('Simple translation test', () => { - console.log('Simple test'); -}); +Esempio('Simple translation test', () => { + console.log('Simple test') +}) Scenario('Simple translation test 2', () => { - console.log('Simple test 2'); -}); + console.log('Simple test 2') +}) Dopo(() => { - console.log('After'); -}); + console.log('After') +})