qtermwidget icon indicating copy to clipboard operation
qtermwidget copied to clipboard

Hovering "Size: X x Y" translated to non-Primary language on macOS

Open apjanke opened this issue 5 years ago • 5 comments

Here's a weird one. I have an English Mac. When I have French installed as one of my preferred languages, but not the Primary one, the hovering "Size:" display when resizing the terminal widget is translated to French.

This affects both QTerminal and the example program included with QTermWidget.

Screen Shot 2019-03-12 at 9 05 24 PM

qterminal-resize-with-french

Expected Behavior

Translation for all UI elements, including this hovering "Size:" display, are translated based on my Primary language.

Current Behavior

Existence of a second preferred language affects translation of the hovering "Size:" display on term widget resize, even when Primary language is not changed.

Removing ~/.config/qterminal.org does not affect it.

Steps to Reproduce (for bugs)

On macOS:

  1. In System Preferences > Language & Region, add another Preferred language, but do not make it your Primary language.
  2. Run qterminal, or example from QTermWidget
  3. Make sure "Show terminal size on resize" is enabled in Preferences > Appearance
  4. Resize the terminal window
System Information
  • Distribution & Version: macOS 10.14.3
  • Kernel: Darwin Kernel Version 18.2.0
  • Qt Version: 5.12.1
  • liblxqt Version: ???
  • Package version: head of master(commit 9ee754a)

apjanke avatar Mar 13 '19 01:03 apjanke

I bet this is because my primary language is English (en), but there's no qtermwidget_en.qm file in share/qtermwidget5/translations in the installation, so Qt's QTranslator falls back to looking for my other preferred languages, and it finds one for fr.

To test this, I removed share/qtermwidget5/translations from my QTermWidget installation and re-ran example. Sure enough, it's now saying "Size: X x Y". Then I did cp qtermwidget_zh_CN.qm qtermwidget_en.qm and re-ran example. Then the "Size:" display was in Chinese.

The doco for QTranslator::load(Qlocale locale, ...) says it uses QLocale::uiLanguages for its search, and not just the locale name. And that's what my uiLanguages() list is.

$ ./example                                                                                                                          master
QLocale::system(): QLocale(English, Latin, United States)
QLocale::system().uiLanguages(): ("en-US", "fr-US")

Maybe a qtermwidget_en.qm needs to be added, that just translates each string to itself? Or has no translations defined at all? Or maybe the translator-loading code could be special-cased to check whether the UI primary languages is English, and since it knows the UI strings are already in English, not load any translators in that case?

apjanke avatar Mar 13 '19 01:03 apjanke

Related references:

  • https://forum.qt.io/topic/62723/qt-widgets-show-german-default-labels-on-uk-windows-system
  • https://forum.qt.io/topic/71000/how-to-clear-qtranslator/3

The last one says to just use lupdate and lrelease to create a no-changes English translation file. I'm not familiar enough with Qt to know how to do that. Can I just create a basically-empty lib/translations/qtermwidget_en.ts file? Or just copy the base qtermwidget.ts to qtermwidget_en.ts?

apjanke avatar Mar 13 '19 02:03 apjanke

I guess some LC_\* environment variables are not correctly set. Before working on this, I'd like to fix QTerminal.app bundle creation first. I'd like to support only one startup method - from launchd - to simplify initialization of environment variables.

yan12125 avatar Apr 11 '19 08:04 yan12125

@apjanke - i would copy it to *en_EN.ts - just give it a try. And yes, you are not alone, at least i heard that some people working on en_EN :)

agaida avatar Aug 27 '19 20:08 agaida

meh - a link should be enough if there is no native en_EN file

agaida avatar Aug 27 '19 20:08 agaida