2017 © Pedro Peláez
 

library codeception-translations

image

phizzl/codeception-translations

  • Thursday, June 15, 2017
  • by phizzl
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,022 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 12 % Grown

The README.md

Translations for Codeception

The module allows you to add translations in your suite config. This may be usefull when working with a multilingual website., (*1)

You may define your translations as module config, (*2)

actor: AcceptanceTester
modules:
    enabled:
        - \Phizzl\Codeception\Modules\Translations\TranslationsModule
    config:
        \Phizzl\Codeception\Modules\Translations\TranslationsModule:
            translations:
                "Welcome friend": "Willkommen Freund"
                "good": "gut"

Of course you can also use environments to have different translations., (*3)

You're also able to load translations from a separate yaml file. Instead filling the translations option with an array structure you can add a file, (*4)

actor: AcceptanceTester
modules:
    enabled:
        - \Phizzl\Codeception\Modules\Translations\TranslationsModule
    config:
        \Phizzl\Codeception\Modules\Translations\TranslationsModule:
            translations: "lang_en.yml"

If you dont use an absolute path the given file will be searched in your configured data directory., (*5)

Now you are able to translate strings in your Cest files., (*6)

public function tryToTest(AcceptanceTester $I)
{
    $welcomeText = $I->translate("Welcome friend"); // result: Willkommen Freund

    $I->amOnPage('/');
    $I->see($welcomeText);

    /* You are also able to translate only placeholder within a string using the defined keys. Just use the ${key} expression in your string. */
    $statusText = $I->translate("Status: \${good}"); // result: Status: gut

    $I->see($statusText);
}

The Versions

15/06 2017
14/06 2017

1.0.0

1.0.0.0

  Sources   Download

GPL-3.0

The Requires