mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-17 15:49:34 +00:00
Replace placeholder syntax for type synonyms to be more DX friendly
Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>
This commit is contained in:
parent
3d3b1f276c
commit
a2f3ceb142
3 changed files with 28 additions and 23 deletions
|
|
@ -18,7 +18,7 @@ perms: # Here comes a list with all Permission names (they have a perm_[name] co
|
|||
|
||||
parts: # e.g. this maps to perms_parts in User/Group database
|
||||
group: "data"
|
||||
label: "{{part}}"
|
||||
label: "[[Part]]"
|
||||
operations: # Here are all possible operations are listed => the op name is mapped to bit value
|
||||
read:
|
||||
label: "perm.read"
|
||||
|
|
@ -71,7 +71,7 @@ perms: # Here comes a list with all Permission names (they have a perm_[name] co
|
|||
|
||||
|
||||
storelocations: &PART_CONTAINING
|
||||
label: "{{storage_location}}"
|
||||
label: "[[Storage_location]]"
|
||||
group: "data"
|
||||
operations:
|
||||
read:
|
||||
|
|
@ -103,39 +103,39 @@ perms: # Here comes a list with all Permission names (they have a perm_[name] co
|
|||
|
||||
footprints:
|
||||
<<: *PART_CONTAINING
|
||||
label: "{{footprint}}"
|
||||
label: "[[Footprint]]"
|
||||
|
||||
categories:
|
||||
<<: *PART_CONTAINING
|
||||
label: "{{category}}"
|
||||
label: "[[Category]]"
|
||||
|
||||
suppliers:
|
||||
<<: *PART_CONTAINING
|
||||
label: "{{supplier}}"
|
||||
label: "[[Supplier]]"
|
||||
|
||||
manufacturers:
|
||||
<<: *PART_CONTAINING
|
||||
label: "{{manufacturer}}"
|
||||
label: "[[Manufacturer]]"
|
||||
|
||||
projects:
|
||||
<<: *PART_CONTAINING
|
||||
label: "{{project}}"
|
||||
label: "[[Project]]"
|
||||
|
||||
attachment_types:
|
||||
<<: *PART_CONTAINING
|
||||
label: "{{attachment_type}}"
|
||||
label: "[[Attachment_type]]"
|
||||
|
||||
currencies:
|
||||
<<: *PART_CONTAINING
|
||||
label: "{{currency}}"
|
||||
label: "[[Currency]]"
|
||||
|
||||
measurement_units:
|
||||
<<: *PART_CONTAINING
|
||||
label: "{{measurement_unit}}"
|
||||
label: "[[Measurement_unit]]"
|
||||
|
||||
part_custom_states:
|
||||
<<: *PART_CONTAINING
|
||||
label: "{{part_custom_state}}"
|
||||
label: "[[Part_custom_state]]"
|
||||
|
||||
tools:
|
||||
label: "perm.part.tools"
|
||||
|
|
|
|||
|
|
@ -60,14 +60,18 @@ readonly class RegisterSynonymsAsTranslationParametersListener
|
|||
|
||||
//Generate a placeholder for each element type
|
||||
foreach (ElementTypes::cases() as $elementType) {
|
||||
//We have a placeholder for singular
|
||||
$placeholders['{' . $elementType->value . '}'] = $this->typeNameGenerator->typeLabel($elementType);
|
||||
//We have a placeholder for plural
|
||||
$placeholders['{{' . $elementType->value . '}}'] = $this->typeNameGenerator->typeLabelPlural($elementType);
|
||||
// Get the capitalized labels
|
||||
$capitalizedSingular = $this->typeNameGenerator->typeLabel($elementType);
|
||||
$capitalizedPlural = $this->typeNameGenerator->typeLabelPlural($elementType);
|
||||
|
||||
// Curly braces for lowercase versions
|
||||
$placeholders['{' . $elementType->value . '}'] = mb_strtolower($capitalizedSingular);
|
||||
$placeholders['{{' . $elementType->value . '}}'] = mb_strtolower($capitalizedPlural);
|
||||
|
||||
//And we have lowercase versions for both
|
||||
$placeholders['[' . $elementType->value . ']'] = mb_strtolower($this->typeNameGenerator->typeLabel($elementType));
|
||||
$placeholders['[[' . $elementType->value . ']]'] = mb_strtolower($this->typeNameGenerator->typeLabelPlural($elementType));
|
||||
// Square brackets for capitalized versions (with capital first letter in placeholder)
|
||||
$capitalizedKey = ucfirst($elementType->value);
|
||||
$placeholders['[' . $capitalizedKey . ']'] = $capitalizedSingular;
|
||||
$placeholders['[[' . $capitalizedKey . ']]'] = $capitalizedPlural;
|
||||
}
|
||||
|
||||
return $placeholders;
|
||||
|
|
|
|||
|
|
@ -40,10 +40,11 @@ class RegisterSynonymsAsTranslationParametersTest extends KernelTestCase
|
|||
$placeholders = $this->listener->getSynonymPlaceholders();
|
||||
|
||||
$this->assertIsArray($placeholders);
|
||||
$this->assertSame('Part', $placeholders['{part}']);
|
||||
$this->assertSame('Parts', $placeholders['{{part}}']);
|
||||
//Lowercase versions:
|
||||
$this->assertSame('part', $placeholders['[part]']);
|
||||
$this->assertSame('parts', $placeholders['[[part]]']);
|
||||
// Curly braces for lowercase versions
|
||||
$this->assertSame('part', $placeholders['{part}']);
|
||||
$this->assertSame('parts', $placeholders['{{part}}']);
|
||||
// Square brackets for capitalized versions (with capital first letter in placeholder)
|
||||
$this->assertSame('Part', $placeholders['[Part]']);
|
||||
$this->assertSame('Parts', $placeholders['[[Part]]']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue