Skip to content

Commit 89fe69d

Browse files
Rely on iconv and symfony/polyfill-*
1 parent a6d32b9 commit 89fe69d

File tree

5 files changed

+4
-17
lines changed

5 files changed

+4
-17
lines changed

DataCollector/TranslationDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private function sanitizeString($string, $length = 80)
137137
{
138138
$string = trim(preg_replace('/\s+/', ' ', $string));
139139

140-
if (function_exists('mb_strlen') && false !== $encoding = mb_detect_encoding($string)) {
140+
if (false !== $encoding = mb_detect_encoding($string, null, true)) {
141141
if (mb_strlen($string, $encoding) > $length) {
142142
return mb_substr($string, 0, $length - 3, $encoding).'...';
143143
}

Loader/XliffFileLoader.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,7 @@ private function extractXliff2(\DOMDocument $dom, MessageCatalogue $catalogue, $
153153
private function utf8ToCharset($content, $encoding = null)
154154
{
155155
if ('UTF-8' !== $encoding && !empty($encoding)) {
156-
if (function_exists('mb_convert_encoding')) {
157-
return mb_convert_encoding($content, $encoding, 'UTF-8');
158-
}
159-
160-
if (function_exists('iconv')) {
161-
return iconv('UTF-8', $encoding, $content);
162-
}
163-
164-
throw new \RuntimeException('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).');
156+
return mb_convert_encoding($content, $encoding, 'UTF-8');
165157
}
166158

167159
return $content;

Tests/Dumper/IcuResFileDumperTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
class IcuResFileDumperTest extends \PHPUnit_Framework_TestCase
1818
{
19-
/**
20-
* @requires extension mbstring
21-
*/
2219
public function testFormatCatalogue()
2320
{
2421
$catalogue = new MessageCatalogue('en');

Tests/Loader/XliffFileLoaderTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ public function testIncompleteResource()
5959
$this->assertEquals(array('foo' => 'bar', 'extra' => 'extra', 'key' => '', 'test' => 'with'), $catalogue->all('domain1'));
6060
}
6161

62-
/**
63-
* @requires extension mbstring
64-
*/
6562
public function testEncoding()
6663
{
6764
$loader = new XliffFileLoader();

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.9"
19+
"php": ">=5.3.9",
20+
"symfony/polyfill-mbstring": "~1.0"
2021
},
2122
"require-dev": {
2223
"symfony/config": "~2.8",

0 commit comments

Comments
 (0)