Skip to content

Commit

Permalink
pref: localize
Browse files Browse the repository at this point in the history
  • Loading branch information
jiannei committed Nov 14, 2023
1 parent 3e2c6ca commit 84f67d9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Support/Traits/EnumEnhance.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function value(): int|string

public function description(string $localizationGroup = 'enums'): string
{
$key = "$localizationGroup.".static::class.'.'.$this->value;
$key = "$localizationGroup.".static::class.'.'.$this->name;

return Lang::has($key) ? Lang::get($key) : Str::of($this->name)->replace('_', ' ')->lower();
}
Expand Down
6 changes: 3 additions & 3 deletions tests/lang/zh_CN.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Jiannei\\Enum\\Laravel\\Tests\\Enums\\UserType": {
"0": "管理员",
"1": "监督员",
"2": "订阅用户"
"ADMINISTRATOR": "管理员",
"MODERATOR": "监督员",
"SUBSCRIBER": "订阅用户"
}
}
6 changes: 3 additions & 3 deletions tests/lang/zh_CN/enums.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

return [
UserType::class => [
UserType::ADMINISTRATOR->value => '管理员',
UserType::MODERATOR->value => '主持人',
UserType::SUBSCRIBER->value => '订阅用户',
UserType::ADMINISTRATOR->name => '管理员',
UserType::MODERATOR->name => '主持人',
UserType::SUBSCRIBER->name => '订阅用户',
],
];

0 comments on commit 84f67d9

Please sign in to comment.