$langaugeItems = [];
foreach ($this->getObjects() as $object) {
foreach ($this->getI18nSaveTypes() as $name => $regex) {
- if ($object->$name === \str_replace('\d+', $object->getObjectID(), $regex)) {
+ if ($object->$name === $this->getLanguageItem($object, $regex)) {
$langaugeItems[] = $object->$name;
}
}
$updateData = $deleteData = [];
foreach ($this->getI18nSaveTypes() as $name => $regex) {
- $languageName = \str_replace('\d+', $object->getObjectID(), $regex);
+ $languageName = $this->getLanguageItem($object, $regex);
if (isset($this->parameters[$name . '_i18n'])) {
I18nHandler::getInstance()->save(
$this->parameters[$name . '_i18n'],
$editor->update($updateData);
}
}
+
+ /**
+ * Formats the language item.
+ */
+ protected function getLanguageItem(DatabaseObject $object, string $regex): string
+ {
+ return \str_replace('\d+', $object->getObjectID(), $regex);
+ }
}
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\box\BoxAction;
use wcf\data\box\BoxEditor;
+use wcf\data\DatabaseObject;
use wcf\data\TI18nDatabaseObjectAction;
use wcf\system\exception\PermissionDeniedException;
public function getI18nSaveTypes(): array
{
return [
- 'title' => 'wcf.menu.com.woltlab.wcf.genericMenu\d+'
+ 'title' => 'wcf.menu.\w+'
];
}
{
return PACKAGE_ID;
}
+
+ protected function getLanguageItem(DatabaseObject $object, string $regex): string
+ {
+ \assert($object instanceof Menu);
+
+ return \str_replace(
+ '\w+',
+ $object->identifier ?: 'com.woltlab.wcf.genericMenu' . $object->menuID,
+ $regex
+ );
+ }
}