How to automatically detect cut-off (too long) strings in localized Qt applications?



  • In my Qt application I have many different screens with localized widgets using Qt's tr(). To determine if a string is displayed correctly without being cut-off we have the following workflow:

    1. English version is checked by the developer implicitly
    2. Translated versions are reviewed manually by native speakers using automatically generated screenshots or the application directly

    The problem is that a manual review process cannot cover 100% of the strings since some texts are only displayed for certain errors or scenarios that cannot be easily reproduced by the reviewers. Languages such as Russian or German tend to have much longer words than English.

    Which approaches do you know to check cut-off/too long strings in any of the translated versions of the software?

    Approaches that I thought about but was not satisfied with:

    • I could loop over all widgets in the application automatically and check the maximum width of the labels. I could then use the font metrics to render the strings off-screen in all languages and compare the maximum width with the actual needed space after rendering and create a log which contains the widget names and strings that fail. The problem is that a lot of the strings are assigned dynamically so I would need to know all permutations of possible texts of all labels.
    • I could (manually?!) define a maximum pixel count for each string and hand this information to the translator. Then the translator could use the exact same font and the exact same font size, render the translated strings and compare the pixel amounts. This approach requires the developer to specify the maximum pixels for each location on the screen which might not even be possible if dynamic layouts are used. It sounds like a tedious job.


  • @FrozenTarzan
    What are you actually trying to achieve? Because if you're saying that the resulting strings could contain unknown, run-time data from the program, you're never going to know exactly how long any string might be, and then an attempt to always know whether it will "fit" will never be 100%.

    Simple answer: don't use fixed-length, maximum length labels or whatever if you expect your application to work identically across languages/varying run-time data. Either allow the labels to grow/wrap, or accept they might be chopped....



  • What are you actually trying to achieve? Because if you're saying that the resulting strings could contain unknown, run-time data from the program, you're never going to know exactly how long any string might be, and then an attempt to always know whether it will "fit" will never be 100%.

    That's my point! :-) A German translator could translate a simple word like "on" into "Oktoberfest" for unknown reasons. The question is how others handle such problems in large UI programs. In my opinion there is no way around a manual review but as a developer I can aid the reviewers as much as possible by automatically finding definite failures before even triggering a (maybe expensive) reviewing process.

    Simple answer: don't use fixed-length, maximum length labels or whatever if you expect your application to work identically across languages/varying run-time data. Either allow the labels to grow/wrap, or accept they might be chopped....

    We are very limited in display size and we don't have a mouse interaction (for scrollbars etc.) or a scale-able Desktop application but work on an embedded device. So I believe that in our case it is actually better to define a hard limit for each label as much as possible because we can then use automated approaches to detect definite failures and therefore aid the reviewing process.

    I think that I will invest some time to read about multi-language UIs unrelated to Qt. Maybe I find different approaches and concepts :-)


  • Lifetime Qt Champion

    Hi,

    You can also resize the text to fit into the label using QFontMetrics.

    Note that in your case, you should also pass requirements to the translators regarding text sizes.



  • You can also resize the text to fit into the label using QFontMetrics.

    Thanks, that's where I would start when writing an automated way to detect terms that are definitely too long for whatever reason (labels might be hard-coded to a too little width, a dynamic layout simply cannot handle impossible strings that just don't fit,...).

    Note that in your case, you should also pass requirements to the translators regarding text sizes.

    We give information about context and sometimes the maximum number of characters where it is necessary. Unfortunately the number of characters is almost useless in space-limited scenarios: "iii" and "WWW" takes up completely different space. This also depends on the used font. This might be a worse-case scenario in English but this actually happens a lot when you support languages such as Russian because their letters seem to be broader compared to English where we have "l", "i", "f", "j", etc. In Russian it seems that almost all letters take up much more space so a character-limit is in practice of no good use.

    I researched different approaches outside the Qt-domain and found the following:

    • OneSky is a company/product that helps to manage translation processes. They basically offer no better system than I have already right now: character maximum (which does not work well as I mentioned above) and some kind of screenshot feature for the context (which we already have and use for manual reviews)
    • In What’s new in localization in Xcode 9 and iOS 11 they also mention that screenshots should be used to send them to translators (which again is a manual review process)
    • Apple mentions pseudo-language testing which I also already do :-)
    • And of course a list of best practices that I already adhere to from the beginning.

    So it seems that there is no standard-way of implementing an automated translation process when it comes to cut-off strings. Developers like me can only implement tools to aid the translators. I think that there cannot be a fully automated solution due to:

    • Context that can often be described perfectly with a simple comment for the translator
    • Dynamic layouts that still do not protect one from too long strings
    • Fixed layouts that of course do not protect one from too long strings but at least make it easy to find wrong terms
    • Esthetics because fitting strings don't necessarily look pleasant to the viewer. It could still look "crammed" in some languages.

  • Lifetime Qt Champion

    With the new trends in machine/deep learning, you might be able to come up with a solution that analyses your application screens to determine whether something is off.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.