mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-18 08:59:30 +00:00
Use defined synonyms in ElementTypeNameGenerator
This commit is contained in:
parent
96418db4e9
commit
e95197b069
2 changed files with 68 additions and 6 deletions
|
|
@ -66,8 +66,37 @@ class DataSourceSynonymsSettings
|
|||
*/
|
||||
public array $customTypeLabels = [];
|
||||
|
||||
public function isCustomLabelDefinedForType(ElementTypes $type): bool
|
||||
/**
|
||||
* Checks if there is any synonym defined for the given type (no matter which language).
|
||||
* @param ElementTypes $type
|
||||
* @return bool
|
||||
*/
|
||||
public function isSynonymDefinedForType(ElementTypes $type): bool
|
||||
{
|
||||
return isset($this->customTypeLabels[$type->value]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singular synonym for the given type and locale, or null if none is defined.
|
||||
* @param ElementTypes $type
|
||||
* @param string $locale
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSingularSynonymForType(ElementTypes $type, string $locale): ?string
|
||||
{
|
||||
return $this->customTypeLabels[$type->value][$locale]['singular'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plural synonym for the given type and locale, or null if none is defined.
|
||||
* @param ElementTypes $type
|
||||
* @param string|null $locale
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPluralSynonymForType(ElementTypes $type, ?string $locale): ?string
|
||||
{
|
||||
return $this->customTypeLabels[$type->value][$locale]['plural']
|
||||
?? $this->customTypeLabels[$type->value][$locale]['singular']
|
||||
?? null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue