function ConfigTranslationUiTest::getPoFile

Same name in other branches
  1. 8.9.x core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::getPoFile()

Helper function that returns a .po file with a given number of plural forms.

2 calls to ConfigTranslationUiTest::getPoFile()
ConfigTranslationUiTest::testPluralConfigStrings in core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php
Tests translation of plural strings with multiple plural forms in config.
ConfigTranslationUiTest::testPluralConfigStringsSourceElements in core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php
Tests plural source elements in configuration translation forms.

File

core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php, line 1207

Class

ConfigTranslationUiTest
Translate settings and entities to various languages.

Namespace

Drupal\Tests\config_translation\Functional

Code

public function getPoFile($plurals) {
    $po_file = [];
    $po_file[1] = <<<EOF
msgid ""
msgstr ""
"Project-Id-Version: Drupal 8\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
"Plural-Forms: nplurals=1; plural=0;\\n"
EOF;
    $po_file[2] = <<<EOF
msgid ""
msgstr ""
"Project-Id-Version: Drupal 8\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
"Plural-Forms: nplurals=2; plural=(n>1);\\n"
EOF;
    $po_file[4] = <<<EOF
msgid ""
msgstr ""
"Project-Id-Version: Drupal 8\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
"Plural-Forms: nplurals=4; plural=(((n%100)==1)?(0):(((n%100)==2)?(1):((((n%100)==3)||((n%100)==4))?(2):3)));\\n"
EOF;
    return $po_file[$plurals];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.