-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-Language Support #2179
Comments
Hi I looked at the link you supplied, but I dont believe that we can use that approach as it is intended for qml which we do not use. However similar functionality exists in C++ Qt already. Strings need to be wrapped in the tr("string") function, and we have already used it it some limited places. https://doc.qt.io/qt-5/i18n-source-translation.html Then I tool can be used to do the actual translation, https://doc.qt.io/qt-5/linguist-translators.html While this approach would work for the GUI elements, there are also messages sent be the "HopsanCore" library (most of the messages that show up in the message widget). This library does not use Qt, so we can not translate those messages using this method. Exactly how to do that will require some research because we try to keep the simulation core "minimal" so a translation library in "plain C++" with no external dependencies would be required. It must also be possible to integrate such a library in a way so that it is possible to compile the Core without it (then defaulting to English). But trying to activate the translation for the GUI could be a start I think. And then see if the Qt lingustics tools are easy to work with. Then many strings in the GUI code needs to be replaced with tr("string") or one of its versions. |
Well i think most important is to use one method in a uniform way. I am just a little afraid if the In my PoV, the translation of the GUI itself should address the majority of needs at least for our case. As soon as engine messages have to be understood by the user, requiring English may be more appropriate (i.e. its sufficient to translate the GUI to include more people as potential users). Plus as soon as the GUI translation is working, translating (at least the most common) info messages from the engine is quite simple to accomplish if we could apply the So should i create a new branch or fork the project? |
Fork and create a new branch in your fork, that is how we work ourselves. |
just an update, I have started trying to figure out how to generate the "ts" translation files from the source code, using CMake and Qt5. I have not figured it out yet though, the instructions are for Qt6 and do not work in Qt5 for some reason, I will try to find a way trigger it manually |
Thank you very much! We really appreciate the time you invest (as we also appreciate Hospan itself). So if you have a fork we can join, please let us know. |
I made some progress, but nothing usable yet, I have a WIP branch here https://github.com/peterNordin/hopsan/tree/issue-2179_translation_support Now cmake build will re-generate/update the example "ts" files whenever I build, next step is figuring out how to translate them using one of the Qt linguistics tools, and how to get the generated "qm" files into the actual program. |
Some more progress. I cleaned up my commits and for-pushed the branch. The code will now.
If you want to try and translate some of the strings you need to install the Qt5 Linguist tool, and open/edit the relevant .ts file in the source code tree in my branch. |
I added a bunch of tr() in the MainWindow code but I realized that there will be a risk for "git conflict" if you start translating and I keep adding tr() to the code and update the translation files. So I think that I should avoid checking in changes to the That way you can focus on the translation and I can focus on the code. (Eventually you may need to help with code as well). Then use the Qt5 Linguist tool to open that file and translate. I will see if I can figure out how to give you push access directly to my branch, otherwise you will need to create pull-requests to my branch. But I think it will be easier if you can push directly. |
Description
For supporting educational scenarios (e.g. automation trainees in Germany), language customization in the Hopsan GUI is desired.
Proposed Solution
As indicated by the QT docs, the usage of
qsTrId
in combination with a respective XML file could in principle do the job.Background
As we are currently investigating the feasibility of using Hopsan in our projects, we consider adding a multi-language support feature and providing a German language translation.
Additional Information Required
The text was updated successfully, but these errors were encountered: