diff --git a/core/modules/config_translation/src/FormElement/PluralVariants.php b/core/modules/config_translation/src/FormElement/PluralVariants.php
index 3c0fbb9..d45a6bd 100644
--- a/core/modules/config_translation/src/FormElement/PluralVariants.php
+++ b/core/modules/config_translation/src/FormElement/PluralVariants.php
@@ -5,6 +5,7 @@
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Config\Config;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
use Drupal\language\Config\LanguageConfigOverride;
/**
@@ -17,7 +18,7 @@ class PluralVariants extends FormElementBase {
*/
protected function getSourceElement(LanguageInterface $source_language, $source_config) {
$plurals = $this->getNumberOfPlurals($source_language->getId());
- $values = explode(LOCALE_PLURAL_DELIMITER, $source_config);
+ $values = explode(PluralTranslatableMarkup::DELIMITER, $source_config);
$element = [
'#type' => 'fieldset',
'#title' => new FormattableMarkup('@label (@source_language)', [
@@ -46,7 +47,7 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
*/
protected function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
$plurals = $this->getNumberOfPlurals($translation_language->getId());
- $values = explode(LOCALE_PLURAL_DELIMITER, $translation_config);
+ $values = explode(PluralTranslatableMarkup::DELIMITER, $translation_config);
$element = [
'#type' => 'fieldset',
'#title' => new FormattableMarkup('@label (@translation_language)', [
@@ -72,7 +73,7 @@ protected function getTranslationElement(LanguageInterface $translation_language
* {@inheritdoc}
*/
public function setConfig(Config $base_config, LanguageConfigOverride $config_translation, $config_values, $base_key = NULL) {
- $config_values = implode(LOCALE_PLURAL_DELIMITER, $config_values);
+ $config_values = implode(PluralTranslatableMarkup::DELIMITER, $config_values);
parent::setConfig($base_config, $config_translation, $config_values, $base_key);
}
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index d4ce174..faa48cd 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -19,6 +19,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
use Drupal\language\ConfigurableLanguageInterface;
use Drupal\Component\Utility\Crypt;
use Drupal\locale\Locale;
@@ -1184,7 +1185,7 @@ function _locale_parse_js_file($filepath) {
// Add string from Drupal.formatPlural().
foreach ($plural_matches[1] as $key => $string) {
$matches[] = [
- 'source' => _locale_strip_quotes($string) . LOCALE_PLURAL_DELIMITER . _locale_strip_quotes($plural_matches[2][$key]),
+ 'source' => _locale_strip_quotes($string) . PluralTranslatableMarkup::DELIMITER . _locale_strip_quotes($plural_matches[2][$key]),
'context' => _locale_strip_quotes($plural_matches[3][$key]),
];
}
diff --git a/core/modules/locale/src/Form/TranslateEditForm.php b/core/modules/locale/src/Form/TranslateEditForm.php
index 659d296..9c8a134 100644
--- a/core/modules/locale/src/Form/TranslateEditForm.php
+++ b/core/modules/locale/src/Form/TranslateEditForm.php
@@ -4,6 +4,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
+use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
use Drupal\locale\SourceString;
/**
@@ -186,7 +187,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// Plural translations are saved in a delimited string. To be able to
// compare the new strings with the existing strings a string in the same
// format is created.
- $new_translation_string_delimited = implode(LOCALE_PLURAL_DELIMITER, $new_translation['translations']);
+ $new_translation_string_delimited = implode(PluralTranslatableMarkup::DELIMITER, $new_translation['translations']);
// Generate an imploded string without delimiter, to be able to run
// empty() on it.
diff --git a/core/modules/locale/src/PoDatabaseWriter.php b/core/modules/locale/src/PoDatabaseWriter.php
index 6ee494d8..dfcd1d7 100644
--- a/core/modules/locale/src/PoDatabaseWriter.php
+++ b/core/modules/locale/src/PoDatabaseWriter.php
@@ -6,6 +6,7 @@
use Drupal\Component\Gettext\PoItem;
use Drupal\Component\Gettext\PoReaderInterface;
use Drupal\Component\Gettext\PoWriterInterface;
+use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
/**
* Gettext PO writer working with the locale module database.
@@ -188,8 +189,8 @@ public function setHeader(PoHeader $header) {
*/
public function writeItem(PoItem $item) {
if ($item->isPlural()) {
- $item->setSource(implode(LOCALE_PLURAL_DELIMITER, $item->getSource()));
- $item->setTranslation(implode(LOCALE_PLURAL_DELIMITER, $item->getTranslation()));
+ $item->setSource(implode(PluralTranslatableMarkup::DELIMITER, $item->getSource()));
+ $item->setTranslation(implode(PluralTranslatableMarkup::DELIMITER, $item->getTranslation()));
}
$this->importString($item);
}
diff --git a/core/modules/locale/src/StringBase.php b/core/modules/locale/src/StringBase.php
index 63cd781..b86e1a0 100644
--- a/core/modules/locale/src/StringBase.php
+++ b/core/modules/locale/src/StringBase.php
@@ -2,6 +2,8 @@
namespace Drupal\locale;
+use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
+
/**
* Defines the locale string base class.
*
@@ -95,14 +97,14 @@ public function setVersion($version) {
* {@inheritdoc}
*/
public function getPlurals() {
- return explode(LOCALE_PLURAL_DELIMITER, $this->getString());
+ return explode(PluralTranslatableMarkup::DELIMITER, $this->getString());
}
/**
* {@inheritdoc}
*/
public function setPlurals($plurals) {
- $this->setString(implode(LOCALE_PLURAL_DELIMITER, $plurals));
+ $this->setString(implode(PluralTranslatableMarkup::DELIMITER, $plurals));
return $this;
}
diff --git a/core/modules/locale/src/StringInterface.php b/core/modules/locale/src/StringInterface.php
index a00dc3e..5f5cc7c 100644
--- a/core/modules/locale/src/StringInterface.php
+++ b/core/modules/locale/src/StringInterface.php
@@ -72,7 +72,8 @@ public function getPlurals();
/**
* Sets this string using array of plural values.
*
- * Serializes plural variants in one string glued by LOCALE_PLURAL_DELIMITER.
+ * Serializes plural variants in one string glued by
+ * Drupal\Core\StringTranslation\PluralTranslatableMarkup::DELIMITER.
*
* @param array $plurals
* Array of strings with plural variants.
diff --git a/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php b/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
index 1d6fde7..7908878 100644
--- a/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
@@ -3,6 +3,7 @@
namespace Drupal\Tests\locale\Functional;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
use Drupal\Tests\BrowserTestBase;
use Drupal\Component\Render\FormattableMarkup;
@@ -51,7 +52,7 @@ public function testFileParsing() {
$source_strings[$string->source] = $string->context;
}
- $etx = LOCALE_PLURAL_DELIMITER;
+ $etx = PluralTranslatableMarkup::DELIMITER;
// List of all strings that should be in the file.
$test_strings = [
'Standard Call t' => '',
diff --git a/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php b/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
index 57916ca..a1ea775 100644
--- a/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
+++ b/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
@@ -186,7 +186,7 @@ public function testPluralEditDateFormatter() {
// not save our source string for performance optimization if we do not ask
// specifically for a language.
\Drupal::translation()->formatPlural(1, '1 second', '@count seconds', [], ['langcode' => 'fr'])->render();
- $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", [':source' => "1 second" . LOCALE_PLURAL_DELIMITER . "@count seconds"])->fetchField();
+ $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", [':source' => "1 second" . PluralTranslatableMarkup::DELIMITER . "@count seconds"])->fetchField();
// Look up editing page for this plural string and check fields.
$search = [
'string' => '1 second',
@@ -270,7 +270,7 @@ public function testPluralEditExport() {
$this->assertText('@count sati');
// Edit langcode hr translations and see if that took effect.
- $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", [':source' => "1 hour" . LOCALE_PLURAL_DELIMITER . "@count hours"])->fetchField();
+ $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", [':source' => "1 hour" . PluralTranslatableMarkup::DELIMITER . "@count hours"])->fetchField();
$edit = [
"strings[$lid][translations][1]" => '@count sata edited',
];
@@ -296,7 +296,7 @@ public function testPluralEditExport() {
// not save our source string for performance optimization if we do not ask
// specifically for a language.
\Drupal::translation()->formatPlural(1, '1 day', '@count days', [], ['langcode' => 'fr'])->render();
- $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", [':source' => "1 day" . LOCALE_PLURAL_DELIMITER . "@count days"])->fetchField();
+ $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", [':source' => "1 day" . PluralTranslatableMarkup::DELIMITER . "@count days"])->fetchField();
// Look up editing page for this plural string and check fields.
$search = [
'string' => '1 day',
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index ac27414..69bc314 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -18,6 +18,7 @@
use Drupal\Core\KeyValueStore\KeyValueDatabaseExpirableFactory;
use Drupal\Core\PageCache\RequestPolicyInterface;
use Drupal\Core\PhpStorage\PhpStorageFactory;
+use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Routing\StackedRouteMatchInterface;
use Drupal\Core\Language\LanguageInterface;
@@ -748,7 +749,7 @@ function system_js_settings_alter(&$settings, AttachedAssetsInterface $assets) {
}
}
if (!isset($settings['pluralDelimiter'])) {
- $settings['pluralDelimiter'] = LOCALE_PLURAL_DELIMITER;
+ $settings['pluralDelimiter'] = PluralTranslatableMarkup::DELIMITER;
}
// Add the theme token to ajaxPageState, ensuring the database is available
// before doing so. Also add the loaded libraries to ajaxPageState.
diff --git a/core/modules/views/src/Plugin/views/field/NumericField.php b/core/modules/views/src/Plugin/views/field/NumericField.php
index 7511334..b89e01f 100644
--- a/core/modules/views/src/Plugin/views/field/NumericField.php
+++ b/core/modules/views/src/Plugin/views/field/NumericField.php
@@ -30,7 +30,7 @@ protected function defineOptions() {
$options['decimal'] = ['default' => '.'];
$options['separator'] = ['default' => ','];
$options['format_plural'] = ['default' => FALSE];
- $options['format_plural_string'] = ['default' => '1' . LOCALE_PLURAL_DELIMITER . '@count'];
+ $options['format_plural_string'] = ['default' => '1' . PluralTranslatableMarkup::DELIMITER . '@count'];
$options['prefix'] = ['default' => ''];
$options['suffix'] = ['default' => ''];
@@ -93,7 +93,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
'#default_value' => $this->options['format_plural_string'],
];
- $plural_array = explode(LOCALE_PLURAL_DELIMITER, $this->options['format_plural_string']);
+ $plural_array = explode(PluralTranslatableMarkup::DELIMITER, $this->options['format_plural_string']);
$plurals = $this->getNumberOfPlurals($this->view->storage->get('langcode'));
for ($i = 0; $i < $plurals; $i++) {
$form['format_plural_values'][$i] = [
@@ -139,7 +139,7 @@ public function submitOptionsForm(&$form, FormStateInterface $form_state) {
// Merge plural format options into one string and drop the individual
// option values.
$options = &$form_state->getValue('options');
- $options['format_plural_string'] = implode(LOCALE_PLURAL_DELIMITER, $options['format_plural_values']);
+ $options['format_plural_string'] = implode(PluralTranslatableMarkup::DELIMITER, $options['format_plural_values']);
unset($options['format_plural_values']);
parent::submitOptionsForm($form, $form_state);
}
diff --git a/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php b/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php
index 08f2504..37c21af 100644
--- a/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php
@@ -4,6 +4,7 @@
use Drupal\Component\Gettext\PoHeader;
use Drupal\file\Entity\File;
+use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
use Drupal\Tests\views\Functional\ViewTestBase;
/**
@@ -45,7 +46,7 @@ public function testNumericFormatPlural() {
$config = $this->config('views.view.numeric_test');
$field_config_prefix = 'display.default.display_options.fields.count.';
$this->assertEqual($config->get($field_config_prefix . 'format_plural'), TRUE);
- $this->assertEqual($config->get($field_config_prefix . 'format_plural_string'), '1' . LOCALE_PLURAL_DELIMITER . '@count');
+ $this->assertEqual($config->get($field_config_prefix . 'format_plural_string'), '1' . PluralTranslatableMarkup::DELIMITER . '@count');
// Assert that the value is displayed.
$this->drupalGet('numeric-test');
@@ -64,7 +65,7 @@ public function testNumericFormatPlural() {
$config = $this->config('views.view.numeric_test');
$field_config_prefix = 'display.default.display_options.fields.count.';
$this->assertEqual($config->get($field_config_prefix . 'format_plural'), TRUE);
- $this->assertEqual($config->get($field_config_prefix . 'format_plural_string'), '1 time' . LOCALE_PLURAL_DELIMITER . '@count times');
+ $this->assertEqual($config->get($field_config_prefix . 'format_plural_string'), '1 time' . PluralTranslatableMarkup::DELIMITER . '@count times');
// Assert that the value is displayed with some sample values.
$numbers = [0, 1, 2, 3, 4, 42];
@@ -107,7 +108,7 @@ public function testNumericFormatPlural() {
$config = $this->config('views.view.numeric_test');
$field_config_prefix = 'display.default.display_options.fields.count.';
$this->assertEqual($config->get($field_config_prefix . 'format_plural'), TRUE);
- $this->assertEqual($config->get($field_config_prefix . 'format_plural_string'), implode(LOCALE_PLURAL_DELIMITER, array_values($edit)));
+ $this->assertEqual($config->get($field_config_prefix . 'format_plural_string'), implode(PluralTranslatableMarkup::DELIMITER, array_values($edit)));
// The view should now use the new plural configuration.
$this->drupalGet('sl/numeric-test');
@@ -120,7 +121,7 @@ public function testNumericFormatPlural() {
// Add an English configuration translation with English plurals.
$english = \Drupal::languageManager()->getLanguageConfigOverride('en', 'views.view.numeric_test');
- $english->set('display.default.display_options.fields.count.format_plural_string', '1 time' . LOCALE_PLURAL_DELIMITER . '@count times')->save();
+ $english->set('display.default.display_options.fields.count.format_plural_string', '1 time' . PluralTranslatableMarkup::DELIMITER . '@count times')->save();
// The view displayed in English should use the English translation.
$this->drupalGet('numeric-test');