Skip to content

Commit

Permalink
refactor(i18n): remove method __()
Browse files Browse the repository at this point in the history
  • Loading branch information
doyouhaobaby committed Aug 6, 2020
1 parent 6022a1f commit 6ec26fa
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 21 deletions.
10 changes: 0 additions & 10 deletions src/Leevel/I18n/I18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ public function __construct(string $i18n)
$this->text[$i18n] = [];
}

/**
* 获取语言 text.
*
* @param array ...$data
*/
public function __(string $text, ...$data): string
{
return $this->gettext($text, ...$data);
}

/**
* 获取语言 text.
*
Expand Down
7 changes: 0 additions & 7 deletions src/Leevel/I18n/II18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@
*/
interface II18n
{
/**
* 获取语言 text.
*
* @param array ...$data
*/
public function __(string $text, ...$data): string;

/**
* 获取语言 text.
*
Expand Down
1 change: 0 additions & 1 deletion src/Leevel/I18n/Proxy/I18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
/**
* 代理 i18n.
*
* @method static string __(string $text, array ...$data) 获取语言 text.
* @method static string gettext(string $text, array ...$data) 获取语言 text.
* @method static void addtext(string $i18n, array $data = []) 添加语言包.
* @method static void setI18n(string $i18n) 设置当前语言包上下文环境.
Expand Down
6 changes: 3 additions & 3 deletions tests/I18n/I18nTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function testBaseUse(): void
'zh-CN' => [],
], $i18n->all());
$this->assertSame('中国语言', $i18n->gettext('中国语言'));
$this->assertSame('中国人语言', $i18n->__('中国%s语言', ''));
$this->assertSame('中国人语言', $i18n->gettext('中国%s语言', ''));
}

/**
Expand All @@ -137,15 +137,15 @@ public function testGetText(): void
$i18n = new I18n('en-US');

$this->assertSame('世界你好', $i18n->gettext('世界你好'));
$this->assertSame('胡巴 ye', $i18n->__('胡巴 %s', 'ye'));
$this->assertSame('胡巴 ye', $i18n->gettext('胡巴 %s', 'ye'));

$i18n->addtext('en-US', [
'世界你好' => 'hello world',
'胡巴 %s' => 'foo %s',
]);

$this->assertSame('hello world', $i18n->gettext('世界你好'));
$this->assertSame('foo ye', $i18n->__('胡巴 %s', 'ye'));
$this->assertSame('foo ye', $i18n->gettext('胡巴 %s', 'ye'));
}

/**
Expand Down

0 comments on commit 6ec26fa

Please sign in to comment.