You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/development/translation.md
+20-93Lines changed: 20 additions & 93 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,11 +28,16 @@ This approach has several advantages:
28
28
29
29
### Using Translations in Code
30
30
31
-
In PHP/Twig:
31
+
In Twig (short syntax):
32
32
```twig
33
33
{{ 'part.info.title'|trans }}
34
34
```
35
35
36
+
In Twig (block syntax for longer text):
37
+
```twig
38
+
{% trans %}part.info.title{% endtrans %}
39
+
```
40
+
36
41
In PHP:
37
42
```php
38
43
$translator->trans('part.info.title')
@@ -59,6 +64,8 @@ The synonym system uses special placeholders in translation strings that get rep
59
64
60
65
Where `Type` is the element type name (e.g., `category`, `part`, `manufacturer`, etc.).
61
66
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
+
62
69
### Available Element Types
63
70
64
71
The following element types support synonyms:
@@ -77,67 +84,13 @@ The following element types support synonyms:
77
84
78
85
### Examples
79
86
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"
130
90
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"
141
94
142
95
### Technical Implementation
143
96
@@ -153,39 +106,13 @@ The system automatically:
153
106
- Falls back to default translations if no synonym is defined
154
107
- Caches placeholder values for performance
155
108
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
184
110
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
0 commit comments