| @@ 77-97 (lines=21) @@ | ||
| 74 | /** |
|
| 75 | * {@inheritdoc} |
|
| 76 | */ |
|
| 77 | public function buildByDomain($domain) |
|
| 78 | { |
|
| 79 | $locales = $this->supportedLocales; |
|
| 80 | foreach ($locales as $key => $locale) { |
|
| 81 | if (!preg_match('/^[a-z]{2}_[a-zA-Z]{2}$|[a-z]{2}/', $locale)) { |
|
| 82 | continue; |
|
| 83 | } |
|
| 84 | $translations = $this->memcached->getItem($locale); |
|
| 85 | if ($translations) { |
|
| 86 | foreach ($translations as $memcacheDomain => $messages) { |
|
| 87 | if ($domain == $memcacheDomain) { |
|
| 88 | foreach ($messages as $ymlKey => $value) { |
|
| 89 | $this->prepareTranslations($domain, $ymlKey, $value, $locale); |
|
| 90 | } |
|
| 91 | } |
|
| 92 | } |
|
| 93 | } |
|
| 94 | } |
|
| 95 | ||
| 96 | return $this->preparedTranslations; |
|
| 97 | } |
|
| 98 | ||
| 99 | /** |
|
| 100 | * {@inheritdoc} |
|
| @@ 102-122 (lines=21) @@ | ||
| 99 | /** |
|
| 100 | * {@inheritdoc} |
|
| 101 | */ |
|
| 102 | public function buildByKey($keyYml) |
|
| 103 | { |
|
| 104 | $locales = $this->supportedLocales; |
|
| 105 | foreach ($locales as $key => $locale) { |
|
| 106 | if (!preg_match('/^[a-z]{2}_[a-zA-Z]{2}$|[a-z]{2}/', $locale)) { |
|
| 107 | continue; |
|
| 108 | } |
|
| 109 | $translations = $this->memcached->getItem($locale); |
|
| 110 | if ($translations) { |
|
| 111 | foreach ($translations as $memcacheDomain => $messages) { |
|
| 112 | foreach ($messages as $ymlKey => $value) { |
|
| 113 | if ($ymlKey == $keyYml) { |
|
| 114 | $this->prepareTranslations($memcacheDomain, $keyYml, $value, $locale); |
|
| 115 | } |
|
| 116 | } |
|
| 117 | } |
|
| 118 | } |
|
| 119 | } |
|
| 120 | ||
| 121 | return $this->preparedTranslations; |
|
| 122 | } |
|
| 123 | ||
| 124 | /** |
|
| 125 | * {@inheritdoc} |
|
| @@ 127-147 (lines=21) @@ | ||
| 124 | /** |
|
| 125 | * {@inheritdoc} |
|
| 126 | */ |
|
| 127 | public function buildByText($text) |
|
| 128 | { |
|
| 129 | $locales = $this->supportedLocales; |
|
| 130 | foreach ($locales as $key => $locale) { |
|
| 131 | if (!preg_match('/^[a-z]{2}_[a-zA-Z]{2}$|[a-z]{2}/', $locale)) { |
|
| 132 | continue; |
|
| 133 | } |
|
| 134 | $translations = $this->memcached->getItem($locale); |
|
| 135 | if ($translations) { |
|
| 136 | foreach ($translations as $memcacheDomain => $messages) { |
|
| 137 | foreach ($messages as $ymlKey => $value) { |
|
| 138 | if (stripos($value, $text) !== false) { |
|
| 139 | $this->prepareTranslations($memcacheDomain, $ymlKey, $value, $locale); |
|
| 140 | } |
|
| 141 | } |
|
| 142 | } |
|
| 143 | } |
|
| 144 | } |
|
| 145 | ||
| 146 | return $this->preparedTranslations; |
|
| 147 | } |
|
| 148 | ||
| 149 | /** |
|
| 150 | * {@inheritdoc} |
|
| @@ 152-170 (lines=19) @@ | ||
| 149 | /** |
|
| 150 | * {@inheritdoc} |
|
| 151 | */ |
|
| 152 | public function getAll() |
|
| 153 | { |
|
| 154 | $locales = $this->supportedLocales; |
|
| 155 | foreach ($locales as $key => $locale) { |
|
| 156 | if (!preg_match('/^[a-z]{2}_[a-zA-Z]{2}$|[a-z]{2}/', $locale)) { |
|
| 157 | continue; |
|
| 158 | } |
|
| 159 | $translations = $this->memcached->getItem($locale); |
|
| 160 | if ($translations) { |
|
| 161 | foreach ($translations as $memcacheDomain => $messages) { |
|
| 162 | foreach ($messages as $ymlKey => $value) { |
|
| 163 | $this->prepareTranslations($memcacheDomain, $ymlKey, $value, $locale); |
|
| 164 | } |
|
| 165 | } |
|
| 166 | } |
|
| 167 | } |
|
| 168 | ||
| 169 | return $this->preparedTranslations; |
|
| 170 | } |
|
| 171 | ||
| 172 | /** |
|
| 173 | * Replace translation by given properties |
|