comparison core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
1 <?php 1 <?php
2 2
3 namespace Drupal\Core\StringTranslation; 3 namespace Drupal\Core\StringTranslation;
4
5 use Drupal\Component\Gettext\PoItem;
4 6
5 /** 7 /**
6 * A class to hold plural translatable markup. 8 * A class to hold plural translatable markup.
7 */ 9 */
8 class PluralTranslatableMarkup extends TranslatableMarkup { 10 class PluralTranslatableMarkup extends TranslatableMarkup {
11 * The delimiter used to split plural strings. 13 * The delimiter used to split plural strings.
12 * 14 *
13 * This is the ETX (End of text) character and is used as a minimal means to 15 * This is the ETX (End of text) character and is used as a minimal means to
14 * separate singular and plural variants in source and translation text. It 16 * separate singular and plural variants in source and translation text. It
15 * was found to be the most compatible delimiter for the supported databases. 17 * was found to be the most compatible delimiter for the supported databases.
18 *
19 * @deprecated in Drupal 8.7.x, will be removed before Drupal 9.0.0.
20 * Use Drupal\Component\Gettext\PoItem::DELIMITER instead.
16 */ 21 */
17 const DELIMITER = "\03"; 22 const DELIMITER = PoItem::DELIMITER;
18 23
19 /** 24 /**
20 * The item count to display. 25 * The item count to display.
21 * 26 *
22 * @var int 27 * @var int
60 * 65 *
61 * @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat() 66 * @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat()
62 */ 67 */
63 public function __construct($count, $singular, $plural, array $args = [], array $options = [], TranslationInterface $string_translation = NULL) { 68 public function __construct($count, $singular, $plural, array $args = [], array $options = [], TranslationInterface $string_translation = NULL) {
64 $this->count = $count; 69 $this->count = $count;
65 $translatable_string = implode(static::DELIMITER, [$singular, $plural]); 70 $translatable_string = implode(PoItem::DELIMITER, [$singular, $plural]);
66 parent::__construct($translatable_string, $args, $options, $string_translation); 71 parent::__construct($translatable_string, $args, $options, $string_translation);
67 } 72 }
68 73
69 /** 74 /**
70 * Constructs a new class instance from already translated markup. 75 * Constructs a new class instance from already translated markup.
110 return ''; 115 return '';
111 } 116 }
112 117
113 $arguments = $this->getArguments(); 118 $arguments = $this->getArguments();
114 $arguments['@count'] = $this->count; 119 $arguments['@count'] = $this->count;
115 $translated_array = explode(static::DELIMITER, $this->translatedString); 120 $translated_array = explode(PoItem::DELIMITER, $this->translatedString);
116 121
117 if ($this->count == 1) { 122 if ($this->count == 1) {
118 return $this->placeholderFormat($translated_array[0], $arguments); 123 return $this->placeholderFormat($translated_array[0], $arguments);
119 } 124 }
120 125