Skip to content

Commit c50f53c

Browse files
authored
Tree: Add native bridge for Translation rewriting to current locale.
1 parent 56428cf commit c50f53c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/SelectboxTree.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function process(array $data): array
3838
} else {
3939
$categoryItem = [
4040
'id' => $item['id'],
41-
'name' => (string) $item['name'],
41+
'name' => $this->normalizeName((string) $item['name']),
4242
'parent' => $item['parent_id'],
4343
];
4444
}
@@ -123,7 +123,7 @@ private function serializeCategoriesToSelectbox(
123123
if ($category['parent'] === $parent) {
124124
if (isset($usedIds[$category['id']]) === false) {
125125
$return[$category['id']] = [
126-
'name' => (string) $category['name'],
126+
'name' => $this->normalizeName((string) $category['name']),
127127
'level' => $level,
128128
];
129129
unset($categories[$catKey]);
@@ -139,4 +139,14 @@ private function serializeCategoriesToSelectbox(
139139

140140
return $return;
141141
}
142+
143+
144+
private function normalizeName(string $name): string
145+
{
146+
if (str_starts_with($name, 'T:{') && class_exists('Baraja\Localization\Translation')) {
147+
return (string) (new \Baraja\Localization\Translation($name));
148+
}
149+
150+
return $name;
151+
}
142152
}

0 commit comments

Comments
 (0)