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: technical/translation.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -134,6 +134,48 @@ print(translate("MyMod", "There are {} widgets present, out of {} total").format
134
134
135
135
(Note that the string sent to translators is "There are {} widgets present, out of {} total" -- the format function is called on the string that is *returned* from the translate function).
136
136
137
+
## Special Cases
138
+
139
+
There are several places in FreeCAD where specific procedures must be followed to ensure translations are correct:
140
+
141
+
### Preference Pages
142
+
143
+
Whether using `addPreferencePage` in Python, or `new Gui::PrefPageProducer` in C++, the "Group" of the page must use the NOOP-functions and the `QObject` context.
new Gui::PrefPageProducer<SomeClass> (QT_TRANSLATE_NOOP("QObject","SomeGroupName"));
152
+
```
153
+
154
+
### Exceptions
155
+
156
+
C++ exceptions that may end up displayed to the user should be put inside a QT_TRANSLATE_NOOP with the `Exception` context, e.g.
157
+
```cpp
158
+
throwMyException(QT_TRANSLATE_NOOP("Exception", "Something bad happened"));
159
+
```
160
+
161
+
### Commands
162
+
163
+
When creating a new command, use the following template:
164
+
```cpp
165
+
CmdDoAThing::CmdDoAThing()
166
+
:Command("MyWorkbench_DoAThing")
167
+
{
168
+
sAppModule = "MyWorkbench";
169
+
sGroup = "MyWorkbench";
170
+
sMenuText = QT_TR_NOOP("Do a thing");
171
+
sToolTipText = QT_TR_NOOP("A longer explanation of doing a thing");
172
+
sWhatsThis = "MyWorkbench_DoAThing";
173
+
sStatusTip = sToolTipText;
174
+
sPixmap = "MyWorkbench_DoAThing";
175
+
}
176
+
```
177
+
Note that `sGroup` should not be translated here (you will still find many counterexamples in older code, however).
178
+
137
179
## UI Files
138
180
139
181
For the most part, all strings in UI files are automatically subject to translation. In some circumstances you may want to *disable* that translation. Using Qt Designer, uncheck the "translatable" checkbox on the widget that you want to disable translation for.
0 commit comments