Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Preferred line break for japanese translation in TS-file
Forum Updated to NodeBB v4.3 + New Features

Preferred line break for japanese translation in TS-file

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 363 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Norme
    wrote on last edited by
    #1

    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&#8203;ThisIsOnANewLine</translation>
    

    since &#8203; 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.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jyothi
      wrote on last edited by Jyothi
      #2

      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

      N 1 Reply Last reply
      0
      • J Jyothi

        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

        N Offline
        N Offline
        Norme
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gongotar
          wrote last edited by
          #4

          What happens when you use &#8203;? does it still break in another position? In that case you might want to combine it with &#x2060; to prevent breaking in other places. Such as これは&#x200B;&#x2060;非常に長い文章です.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved