2017 © Pedro Peláez
 

behat-extension multilingual-extension

Behat extension for testing multilingual sites

image

kolev/multilingual-extension

Behat extension for testing multilingual sites

  • Monday, February 26, 2018
  • by byKolev
  • Repository
  • 1 Watchers
  • 4 Stars
  • 3,154 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 3 Versions
  • 13 % Grown

The README.md

Behat MutlilingualExtension

Write tests once, test on multiple languages

Behat extension to help you do less work when you have multilanguage environment., (*1)

MultilingualExtension is a Behat extension designed to ease the work with multilingual sites. English language is used as a base and translations for each string are stored in a user defined file. The main idea is to write your tests in English language and then run them against sites with different language than English. The website language is defined in YML profile., (*2)

Note that it is in very early version so some features may not work properly., (*3)

Latest Stable Version License Coverage Status Quality Score Build Status Total Downloads, (*4)

Installation

  • curl -sS https://getcomposer.org/installer | php
  • vim composer.json
{
  "require": {
    "kolev/multilingual-extension": "dev-master"
  },
  "config": {
    "bin-dir": "bin"
  }
}
  • composer install

Usage

MultilingualExtension is easy to use. First you need to add the extension to your profile in behat.yml configuration file., (*5)

german_profile:
  suites:
    default:
      contexts: {}
  extensions:
    Behat\MinkExtension:
      files_path: %paths.base%/files
    kolev\MultilingualExtension:
      default_language: de
      translations: translations.yml

The default_language variable is used to define the website's default language. The translations variable is used to define the path to the translations file. The path is relative to the files_path variable. So in this case the translations.yml file should be placed in /files folder., (*6)

The translations.yml file structure is easy to read too., (*7)

"carrot":
  de: "karrote"
  fr: "carrote"
"cabbage":
  de: "kohl"
  fr: "chou"

The user can list as many words as he/she wants. Also many different languages for each word can be added., (*8)

It is important to use the same language prefix in translations.yml file and when configuring the profile. For example define site's language as de and add translations with de., (*9)

Then it's time to write your test porperly in order to use the localized version of the string. For example:, (*10)

Feature: Multilingual Extension example feature

  Scenario: Example of a Scenario for testing multilingual extension
    Given I go to "/"
    And I should see localized "carrot"

In this case if your run the test with german_profile it will open the homepage and look for de version of the word carrot which in our case is karrote., (*11)

FAQ

What if I have more than one language installed?

Language detection based on URL is introduced with version 0.0.2. The extension tries to detect site's language based on URL. For example if you go to page http://example.com/de/ it will look for German translation of the string, if no language code found it will use the default_language. It works for both clean and non-clean URLs., (*12)

What are the availabe languages supported?

List of all languages ISO codes can be found here, (*13)

Author

Contributors

The Versions

26/02 2018

dev-master

9999999-dev

Behat extension for testing multilingual sites

  Sources   Download

GNU

The Requires

 

by Toni Kolev

test testing extension behat drupal multilingual web multilanguage

13/07 2016

0.0.2

0.0.2.0

Behat extension for testing multilingual sites

  Sources   Download

GNU

The Requires

 

by Toni Kolev

test testing extension behat drupal multilingual web multilanguage

08/07 2016

0.0.1

0.0.1.0

Behat extension for testing multilingual sites

  Sources   Download

GNU

The Requires

 

by Toni Kolev

test testing extension behat drupal multilingual web multilanguage