【问题标题】:Where are the translations in cucumber/gherkin?黄瓜/小黄瓜的翻译在哪里?
【发布时间】:2015-12-13 22:31:48
【问题描述】:

我想把这个小黄瓜场景翻译成法语。

Feature: Test the validation on the person object

  Background:
    Given the language is 'english'

  Scenario: Create a person with firstName empty and check we have a violation error message on it
    Given we create a new person
    And we set firstName ''
    And we set lastName 'smith'
    When we apply validation
    Then we should have 1 violation
    And we should have a  error message on 'firstName' that says 'may not be empty'

但是我没有看到 Background 的翻译在哪里,并且我(偶然)发现 Java @Etantdonné(类似于 @Given)中的注释实际上用在带有空格的功能文件中:“Etant donné ”。

我在黄瓜网站文档中找不到关于这一点的信息。

谁能给我一个链接来了解如何在黄瓜/小黄瓜中使用 i18n ?

【问题讨论】:

    标签: internationalization cucumber cucumber-jvm gherkin


    【解决方案1】:

    查看可用语言列表

    > cucumber --i18n help
    

    列出特定语言的关键字

    > cucumber --i18n <language_code>
    
    > cucumber --i18n fr
    

    对于 Java,您需要一个完整的命令行: java -cp "jars/*" cucumber.api.cli.Main --i18n fr (其中“jars/*”是你的 Cucumber/Gherkin jars 所在的文件夹)

    功能文件中的标题

    请记住,任何不同于en 的语言都应在*.feature file 的开头使用# language: ... 注释明确标记:

    例子:
    # language: fr
    **Fonctionnalité: ...**
    ...
    

    法语。如果省略此标头,Cucumber 将默认为英文(en)

    这样,您的功能将保存有关其内容类型的所有信息,这对于 BDD 等方法非常重要,并且还使 Cucumber 能够在一个套件中拥有多语言功能。

    所有小黄瓜单词都已翻译

    例如法语:

    • 场景 - Scénario

    • 场景大纲 - Plan du scénario or Plan du Scénario

    • 然后 - Alors

    • 当 - Quand

    • AND - Et que

    • 但是 - Mais que

    等等……

    语言的 Cucumber JSON 数据

    你可以在这里找到 Gherkin 的所有翻译https://github.com/cucumber/gherkin3/blob/master/gherkin-languages.json

    法语的 JSON 数据

    fr: {
    and: [
    "* ",
    "Et que ",
    "Et qu'",
    "Et "
    ],
    background: [
    "Contexte"
    ],
    but: [
    "* ",
    "Mais que ",
    "Mais qu'",
    "Mais "
    ],
    examples: [
    "Exemples"
    ],
    feature: [
    "Fonctionnalité"
    ],
    given: [
    "* ",
    "Soit ",
    "Etant donné que ",
    "Etant donné qu'",
    "Etant donné ",
    "Etant donnée ",
    "Etant donnés ",
    "Etant données ",
    "Étant donné que ",
    "Étant donné qu'",
    "Étant donné ",
    "Étant donnée ",
    "Étant donnés ",
    "Étant données "
    ],
    name: "French",
    native: "français",
    scenario: [
    "Scénario"
    ],
    scenarioOutline: [
    "Plan du scénario",
    "Plan du Scénario"
    ],
    then: [
    "* ",
    "Alors "
    ],
    when: [
    "* ",
    "Quand ",
    "Lorsque ",
    "Lorsqu'"
    ]
    },
    

    希望对你有帮助...

    【讨论】:

    • 当然,对于 Java,您需要一个完整的命令行: java -cp "jars/*" cucumber.api.cli.Main --i18n fr (其中 "jars/*" 是你的黄瓜/小黄瓜罐子所在的文件夹)
    • 完美,谢谢。我把你的答案放在wiki of cucumber
    • @MichaelCourcy.,太棒了!该怎么做?
    • 使用您的 github 帐户继续该项目并在 wiki 上创建一个页面。
    • 亲爱的@MichaelCourcy,我已经修改了 Cucumber wiki。立即检查。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多