Skip to content

Commit b36aeec

Browse files
committed
Revert "Use string template engine to render language translations"
This reverts commit 3e1b965. Signed-off-by: Jack Cherng <[email protected]>
1 parent 0a991e7 commit b36aeec

File tree

5 files changed

+14
-69
lines changed

5 files changed

+14
-69
lines changed

.phan/config.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
'src',
1919
'vendor/jfcherng/php-mb-string/src',
2020
'vendor/jfcherng/php-sequence-matcher/src',
21-
'vendor/nicmart/string-template/src',
2221
],
2322

2423
// A directory list that defines files that will be excluded

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"require": {
2929
"php": "^7.1.3",
3030
"jfcherng/php-mb-string": "^1.3",
31-
"jfcherng/php-sequence-matcher": "^3.2",
32-
"nicmart/string-template": "~0.1"
31+
"jfcherng/php-sequence-matcher": "^3.2"
3332
},
3433
"require-dev": {
3534
"friendsofphp/php-cs-fixer": "^2.16",

composer.lock

Lines changed: 6 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Renderer/AbstractRenderer.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,14 @@ protected function updateLanguage($old, $new): self
182182
/**
183183
* A shorthand to do translation.
184184
*
185-
* @param string $text The text
186-
* @param array $placeholders The placeholders
187-
* @param bool $escapeHtml Escape the translated text for HTML?
185+
* @param string $text The text
186+
* @param bool $escapeHtml Escape the translated text for HTML?
188187
*
189188
* @return string the translated text
190189
*/
191-
protected function _(string $text, array $placeholders = [], bool $escapeHtml = true): string
190+
protected function _(string $text, bool $escapeHtml = true): string
192191
{
193-
$text = $this->t->translate($text, $placeholders);
192+
$text = $this->t->translate($text);
194193

195194
return $escapeHtml ? \htmlspecialchars($text) : $text;
196195
}

src/Utility/Language.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,8 @@
44

55
namespace Jfcherng\Diff\Utility;
66

7-
use StringTemplate\Engine as StringTemplateEngine;
8-
97
final class Language
108
{
11-
/**
12-
* @var \StringTemplate\Engine
13-
*/
14-
private $stringEngine;
15-
169
/**
1710
* @var string[] the translation dict
1811
*/
@@ -30,7 +23,6 @@ final class Language
3023
*/
3124
public function __construct($target = 'eng')
3225
{
33-
$this->stringEngine = new StringTemplateEngine('{', '}');
3426
$this->setLanguageOrTranslations($target);
3527
}
3628

@@ -108,14 +100,11 @@ public static function getTranslationsByLanguage(string $language): array
108100
/**
109101
* Translation the text.
110102
*
111-
* @param string $text the text
112-
* @param array $placeholders the placeholders
103+
* @param string $text the text
113104
*/
114-
public function translate(string $text, array $placeholders = []): string
105+
public function translate(string $text): string
115106
{
116-
return isset($this->translations[$text])
117-
? $this->stringEngine->render($this->translations[$text], $placeholders)
118-
: "![{$text}]";
107+
return $this->translations[$text] ?? "![{$text}]";
119108
}
120109

121110
/**

0 commit comments

Comments
 (0)