phizzl / codeception-translations
Installs: 1 864
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- codeception/codeception: ^2.3
- symfony/yaml: >=2.7 <4.0
This package is auto-updated.
Last update: 2022-11-12 23:25:52 UTC
README
The module allows you to add translations in your suite config. This may be usefull when working with a multilingual website.
You may define your translations as module config
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.
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
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.
Now you are able to translate strings in your Cest files.
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); }