Preferred line break for japanese translation in TS-file
-
Hi,
I have a TS-file with japanese translations and some translations are used in multiple places. The issue arise when some places requires the text to be wrapped. This works fine for most other languages, such as english, since we can split the text for example at a word boundary. This is, however, not possible in japanese and for now it splits at a character when there is no more room available at the component. What I would like to do, is modify the translation so that I can have a preferred line break position. As an example, given the following translation:
<translation>これは非常に長い文章です</translation>
How can we modify it, e.g., with HTML/CSS(?) to make a line break at the third character if a line break is needed, otherwise don't break. If it would be english, we could do the following:
<translation>ThisIsALongText​ThisIsOnANewLine</translation>
since
​
for example indicates zero width space. This does not work for japanese. So far I have tried all kinds of kombinations using the HTML/CSS-subset that QT has. For example:<translation>これは<span style="display: inline-block; white-space: nowrap;">非常に長い文章です</span></translation>
or
<translation>これは<div style="display: inline-block; white-space: nowrap;">非常に長い文章です</div></translation>
Neither of these or any other combination I can come up with works 100%. Either it correctly works for the line break but then also break when it has room and should not break, or it doesn't line break correctly at all.
Do anyone have any suggestions what I might try? Thanks in advance.
-
Hello!!
I don't know if this helps or not, Previously I've done translation of english text to russian text. However, I was using Qt creator (C++). With Qt creator, I was able to generate .ts file which contains all the words which are visible on GUI. If you are giving any text which is visible on GUI through code, you can put tr() around that text like, tr("example_text_on_GUI"). This generated .ts file can be opened Qt5 Linguist. In Qt5 Linguist, you can give translations according to your wish (with line break, tab space etc.,).After giving all the translations in Qt5 Linguist, you can generate .qm file from Qt5 Linguist. This file can be used to translate all the text from first language to your second language using QTranslator
In QML, the way of writing maybe different, but I think works in that to. You can try QTranslator with the help of chatgpt or any other gpts
I hope this helps, you can try this and reply if you face in issues in the procedure
-
Hello!!
I don't know if this helps or not, Previously I've done translation of english text to russian text. However, I was using Qt creator (C++). With Qt creator, I was able to generate .ts file which contains all the words which are visible on GUI. If you are giving any text which is visible on GUI through code, you can put tr() around that text like, tr("example_text_on_GUI"). This generated .ts file can be opened Qt5 Linguist. In Qt5 Linguist, you can give translations according to your wish (with line break, tab space etc.,).After giving all the translations in Qt5 Linguist, you can generate .qm file from Qt5 Linguist. This file can be used to translate all the text from first language to your second language using QTranslator
In QML, the way of writing maybe different, but I think works in that to. You can try QTranslator with the help of chatgpt or any other gpts
I hope this helps, you can try this and reply if you face in issues in the procedure
@Jyothi Thanks for the response. I have no problem with using translations in QT, I do it for multiple languages. The problem is that one translation is used in multiple places, and thus I want to incorporate preferred line break in the translation itself. The other option is to duplicate the translation string and use one on each place, but that quickly turns cumbersome when you have thousands of strings. I try to minimize the amount of duplicated strings in the application.