Skip to content

Commit 1894d61

Browse files
Copilotjbtronics
andcommitted
Address feedback: add trans/endtrans syntax, inflection note, reduce verbosity
Co-authored-by: jbtronics <[email protected]>
1 parent 0433651 commit 1894d61

File tree

1 file changed

+20
-93
lines changed

1 file changed

+20
-93
lines changed

docs/development/translation.md

Lines changed: 20 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ This approach has several advantages:
2828

2929
### Using Translations in Code
3030

31-
In PHP/Twig:
31+
In Twig (short syntax):
3232
```twig
3333
{{ 'part.info.title'|trans }}
3434
```
3535

36+
In Twig (block syntax for longer text):
37+
```twig
38+
{% trans %}part.info.title{% endtrans %}
39+
```
40+
3641
In PHP:
3742
```php
3843
$translator->trans('part.info.title')
@@ -59,6 +64,8 @@ The synonym system uses special placeholders in translation strings that get rep
5964

6065
Where `Type` is the element type name (e.g., `category`, `part`, `manufacturer`, etc.).
6166

67+
**Note for inflected languages**: In languages like German where words are inflected (e.g., case declensions), synonyms should be defined in the nominative case (the standard/dictionary form). The placeholders will be substituted as-is, so translations need to be written to work with the nominative form.
68+
6269
### Available Element Types
6370

6471
The following element types support synonyms:
@@ -77,67 +84,13 @@ The following element types support synonyms:
7784

7885
### Examples
7986

80-
#### Basic Usage
81-
82-
Translation string:
83-
```
84-
"Click here to create a new [Category]"
85-
```
86-
87-
Default output:
88-
```
89-
"Click here to create a new Category"
90-
```
91-
92-
With custom synonym (Category → "Product Type"):
93-
```
94-
"Click here to create a new Product Type"
95-
```
96-
97-
#### Multiple Placeholders
98-
99-
Translation string:
100-
```
101-
"This [part] belongs to [category] 'Electronics'"
102-
```
103-
104-
Default output:
105-
```
106-
"This part belongs to category 'Electronics'"
107-
```
108-
109-
With custom synonyms:
110-
```
111-
"This component belongs to product group 'Electronics'"
112-
```
113-
114-
#### Plural Usage
115-
116-
Translation string:
117-
```
118-
"You have 5 [[part]] in 3 [[category]]"
119-
```
120-
121-
Default output:
122-
```
123-
"You have 5 parts in 3 categories"
124-
```
125-
126-
With custom synonyms (Part → "Component", Category → "Group"):
127-
```
128-
"You have 5 components in 3 groups"
129-
```
87+
**Example 1**: `"Click here to create a new [Category]"`
88+
- Default: "Click here to create a new Category"
89+
- With synonym (Category → "Product Type"): "Click here to create a new Product Type"
13090

131-
#### Case Variations
132-
133-
Translation string:
134-
```
135-
"Select a [Category] to view its [[part]]"
136-
```
137-
138-
This demonstrates:
139-
- `[Category]` - Capitalized singular (starts sentence or emphasizes)
140-
- `[[part]]` - Lowercase plural (mid-sentence)
91+
**Example 2**: `"You have 5 [[part]] in 3 [[category]]"`
92+
- Default: "You have 5 parts in 3 categories"
93+
- With synonyms (Part → "Component", Category → "Group"): "You have 5 components in 3 groups"
14194

14295
### Technical Implementation
14396

@@ -153,39 +106,13 @@ The system automatically:
153106
- Falls back to default translations if no synonym is defined
154107
- Caches placeholder values for performance
155108

156-
### Guidelines for Using Synonyms in Translations
157-
158-
When writing or updating translation strings:
159-
160-
1. **Use synonyms for entity type references**: When referring to entity types like categories, parts, manufacturers, etc., use the synonym placeholders instead of hardcoding the type name.
161-
162-
✅ Good: `"Delete this [category]?"`
163-
164-
❌ Bad: `"Delete this category?"`
165-
166-
2. **Match the case to context**:
167-
- Use capitalized forms (`[Type]`, `[[Type]]`) at the start of sentences or for emphasis
168-
- Use lowercase forms (`[type]`, `[[type]]`) in the middle of sentences
169-
170-
3. **Choose singular vs. plural appropriately**:
171-
- Use singular for single items: `"Create new [part]"`
172-
- Use plural for multiple items or lists: `"Available [[part]]"`
173-
174-
4. **Consistency**: Be consistent with placeholder usage across similar translation strings
175-
176-
5. **Don't overuse**: Only use placeholders for actual entity type names. Don't use them for:
177-
- Action verbs (use regular translations)
178-
- Specific feature names
179-
- UI element names that aren't entity types
180-
181-
### Testing Synonyms
182-
183-
To test how your translations work with synonyms:
109+
### Guidelines for Using Synonyms
184110

185-
1. Go to Settings → Synonyms in Part-DB
186-
2. Define custom synonyms for the types you're testing
187-
3. Navigate to pages that use your translation strings
188-
4. Verify the synonyms appear correctly with proper capitalization and plurality
111+
When writing translation strings:
112+
- Use placeholders for entity types (✅ `"Delete this [category]?"``"Delete this category?"`)
113+
- Match case to context: capitalized (`[Type]`, `[[Type]]`) at sentence start, lowercase (`[type]`, `[[type]]`) mid-sentence
114+
- Use singular for single items, plural for multiple items
115+
- Only use for actual entity type names, not for actions or feature names
189116

190117
## Translation Parameters
191118

0 commit comments

Comments
 (0)