NAME

Gherkin::Dialect - Dictionary holding keyword translations

SYNOPSIS

use Gherkin::Dialect;

my $dialect = Gherkin::Dialect->new( { dialect => 'em' } );

# Print the names of the steps in the current dialect:
for my $keyword (qw/ Given When Then /) {
  print "Translations for $keyword:\n";
  for my $translation (@{ $dialect->$keyword }) {
    print " - $translation\n";
  }
}

DESCRIPTION

Dialects represent translations of the keywords in the Gherkin language. This module implements a class to manage a set of these dialects and select the one to be used for keyword translation lookup. Out of the box, Gherkin comes with actual translations, such as Afrikaans as well as 'slang-like' translations such as "Pirate English".

This module is used by the token matcher to identify the type of token (input line) passed to the scanner.

METHODS

new( $options )

Constructor.

$options is a hashref with some of the following keys:

  • dialect

    The name of the dialect to use for translation lookup. Defaults to 'en'.

  • dictionary

    A hash of hashes, with the names of the dialects as the keys of the primary hash and the names of the Gherkin keywords as the keys of the secondary hashes (with the values of the secondary hashes being arrayrefs holding the actual translations of the keyword).

    Mutually exclusive with dictionary_location.

  • dictionary_location

    Pathname to a JSON file which deserializes into the structure mentioned for the dictionary option.

    Mutually exclusive with dictionary_location.

In case neither dictionary nor dictionary_location is specified, the default dictionary from the Cucumber project is loaded.

change_dialect( $new_dialect )

Selects a dialect for translation lookup from the current dictionary.

TRANSLATION LOOKUP FUNCTIONS

  • Feature

  • Rule

  • Scenario

  • Background

  • Examples

  • Given

  • When

  • Then

  • And

  • But

  • ScenarioOutline

SEE ALSO

LICENSE

See Gherkin