gui: fix language list #16808

pull GChuf wants to merge 1 commits into bitcoin:master from GChuf:translation-list-fix changing 1 files +29 −5
  1. GChuf commented at 6:24 PM on September 5, 2019: contributor

    This commit stylizes the language list by replacing applicable first characters in language names with uppercase symbols, and manually fixes some languages that are otherwise not displayed (on windows and ubuntu for now). Example given on the picture is Esperanto.

    Manual fixes only occur when the initial string is empty.

    If there are any other languages not displayed correctly on mac systems, let me know.

    Before and after (Ubuntu 16, with stylizing): before1 after1

  2. in src/qt/optionsdialog.cpp:105 in cf5a6157a7 outdated
     104 | -        if(langStr.contains("_"))
     105 | +        if(locale.nativeLanguageName().length()==0) /* If locale name is an empty string, fix it manually. */
     106 |          {
     107 | -            /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
     108 | -            ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
     109 | +            if(langStr.contains("szl"))
    


    emilengler commented at 7:18 PM on September 5, 2019:

    Take a look at the coding guidelines please


    GChuf commented at 8:06 PM on September 5, 2019:

    Where could I find that?


    jonatack commented at 8:12 PM on September 5, 2019:

    GChuf commented at 11:15 PM on September 5, 2019:

    @jonatack thank you. I did a quick search but was not able to find where the guidelines are. @emilengler I've since updated the file.

  3. emilengler commented at 7:20 PM on September 5, 2019: contributor

    Concept NACK. In some languages it might be grammatically incorrect to write it uppercase. Also in languages like "Deutsch" or "espanol de Espana" it is already grammatically correct

  4. GChuf commented at 8:06 PM on September 5, 2019: contributor

    Yes, uppercase might be gramatically incorrect in some cases. (It could be argued however that these names are not in the middle of a sentence, but rather at the start - which would justify the use of capital letters ...)

    Anyway, gramatically correct or not, the updated list seems much clearer / easier to glance through to me. Looks nicer as well. That's what I was trying to improve. I don't think grammar plays a big role in this list, even though I like to see correct grammar being used everywhere.

  5. DrahtBot added the label GUI on Sep 5, 2019
  6. in src/qt/optionsdialog.cpp:177 in e2dae930c1 outdated
     173 | @@ -148,7 +174,7 @@ void OptionsDialog::setModel(OptionsModel *_model)
     174 |  {
     175 |      this->model = _model;
     176 |  
     177 | -    if(_model)
     178 | +    if (_model)
    


    fanquake commented at 7:57 AM on September 6, 2019:

    Please don't include unrelated styling changes (even if they may be correct) in commits.


    GChuf commented at 10:00 AM on September 6, 2019:

    ok - I thought that was an appropriate thing to do after emil mentioned coding guidelines. is there another way/place to do this then?


    fanquake commented at 10:03 AM on September 6, 2019:

    Not unless you happen to be changing the same line while making another significant change. We don't want style change/formatting only PRs.

  7. fanquake renamed this:
    GUI: fix and stylize language list
    gui: fix and stylize language list
    on Sep 6, 2019
  8. fanquake changes_requested
  9. fanquake commented at 8:06 AM on September 6, 2019: member

    Concept NACK - Can this be fixed upstream or in the translation files somehow, rather than adding language specific workarounds to the GUI code? This seems brittle; i.e is it possible that another language string in the future contains pam or szl?. Will defer to @laanwj.

    Anyway, gramatically correct or not,

    I think a drop-down list of language names is probably one of the places you actually would want to be grammatically correct. Otherwise I'd assume after the next release we'll have someone opening a PR to "fix" the incorrect display of their language.

  10. GChuf commented at 9:57 AM on September 6, 2019: contributor

    Can this be fixed upstream or in the translation files somehow, rather than adding language specific workarounds to the GUI code?

    No, the locale names are pulled from the host OS I think. In other words, linux and windows don't know what language "szl" is.

    is it possible that another language string in the future contains pam or szl?

    Very unlikely, there are no other languages on transifex that would contain these strings. I was thinking about whether or not to include and langStr.length()==3 for pam and szl as well - I suppose I should have anyway.

    I think a drop-down list of language names is probably one of the places you actually would want to be grammatically correct. Otherwise I'd assume after the next release we'll have someone opening a PR to "fix" the incorrect display of their language.

    "Incorrect display of their language" seems like an overkill to me - like I mentioned, it could be argued that the display is indeed gramatically correct. My goal was to stylize the list. If the language names were in the middle of a sentence, there would be no dispute over grammar - some languages must stay lowercase. But in a list? I myself can search through that list faster if all first symbols appear the same - not some uppercase, some lowercase.

  11. GChuf commented at 10:03 AM on September 6, 2019: contributor

    Seems like Windows (also Microsoft Word) would agree with my reasoning - lists use uppercase. Screenshot_102

  12. jonatack commented at 10:25 AM on September 6, 2019: member

    @GChuf here is a document I've been compiling for the past six months that you might find useful (apologies if not). Also, if you really want to open PRs, one possible humble suggestion (that I myself should heed more often) is to watch for "would-be-nice-to-have" requests by long-term contributors (that you will see when reviewing PRs and observing on IRC) and to look at the issues tagged as "good first issues".

  13. in src/qt/optionsdialog.cpp:105 in 958d54e320 outdated
     104 | -        if(langStr.contains("_"))
     105 | +        if (locale.nativeLanguageName().length()==0) /* If locale name is an empty string, fix it manually. */
     106 |          {
     107 | -            /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
     108 | -            ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
     109 | +            if (langStr.contains("szl") and langStr.length()==3)
    


    practicalswift commented at 11:30 AM on September 7, 2019:

    Use && instead of and -- applies throughout this PR :-)


    GChuf commented at 7:34 PM on September 8, 2019:

    fixed!

  14. GChuf commented at 7:38 PM on September 8, 2019: contributor

    Fixed commit based on practicalswift's review. @jonatack thank you for sharing the doc. Unfortunately most of requests and other PRs exceed my knowledge, as some already know I'm sure.

  15. laanwj commented at 7:31 AM on September 10, 2019: member

    Thanks for trying to improve things there ! ACK on adding languages that are completely missing. That fixes an actual issue. NACK on "stylizing" this list if it adds all kind of special-case custom code.

    In some languages it might be grammatically incorrect to write it uppercase.

    Yes, the assumption that names are capitalized by the first letter is very much a western one. Or maybe even English. I often see my name capitalized as "Van der Laan", for example.

  16. jonatack commented at 7:43 AM on September 10, 2019: member

    @jonatack thank you for sharing the doc. Unfortunately most of requests and other PRs exceed my knowledge, as some already know I'm sure.

    No worries, same for me, when it comes to Bitcoin we all start from somewhere! There is a self-study club at https://bitcoin-core-review-club.github.io, don't hesitate to prepare and participate :)

  17. GChuf commented at 11:40 AM on September 11, 2019: contributor

    @laanwj I see your point. Given that there's not much support for capitalizing anyway, I removed that code and only left "manual fixes". If there are any other languages not being displayed correctly (I can't test for macOS), let me know and I'll include them.

  18. gui: fix language list
    Manually fixes some language names which were not displayed correctly
    27a158617c
  19. GChuf renamed this:
    gui: fix and stylize language list
    gui: fix language list
    on Sep 12, 2019
  20. luke-jr commented at 11:08 PM on September 20, 2019: member

    NACK, this seems like a hack for upstream/OS issues. Presumably whoever uses these languages will have an OS that can handle them anyway?

  21. MarcoFalke added the label Upstream on Sep 21, 2019
  22. GChuf commented at 10:55 AM on October 1, 2019: contributor

    NACK, this seems like a hack for upstream/OS issues. Presumably whoever uses these languages will have an OS that can handle them anyway?

    You might be right, but I'm not sure - I do have the option to use silesian/esperanto... languages on my Windows 10 machine for example, but they're still not displayed correctly in bitcoin-qt. This is an upstream hack and it's not elegant, but it does fix the display issue and it might actually help someone who wants to use silesian.

  23. MarcoFalke commented at 11:16 AM on October 1, 2019: member

    Could you create or link to an upstream bug, to make sure that upstream is aware of this and maybe see their opinion on this issue?

  24. emilengler commented at 3:13 PM on October 4, 2019: contributor

    @GChuf Is there no possible other way? I dont't think that hard coded stuff is the right way to fix.

    Maybe we could get a list of the languages by the os and then have a list with the languages bitcoin-qt supports. It will then drop out all elements which are not supported by bitcoin-qt

  25. GChuf commented at 5:25 PM on October 4, 2019: contributor

    @emilengler there are other ways, this was the only way I could make it work though. If someone finds a better solution, by all means, create a PR.

    p.s. check this link about qt and locales.

  26. in src/qt/optionsdialog.cpp:103 in 27a158617c
      97 | @@ -98,15 +98,39 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
      98 |      {
      99 |          QLocale locale(langStr);
     100 |  
     101 | -        /** check if the locale name consists of 2 parts (language_country) */
     102 | -        if(langStr.contains("_"))
     103 | +        if (locale.nativeLanguageName().length()==0) /* If locale name is an empty string, fix it manually. */
     104 |          {
     105 | -            /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
     106 | +            if (langStr.contains("szl") && langStr.length()==3)
    


    laanwj commented at 10:59 AM on October 30, 2019:

    instead of this long if() statement and repeated code, please make this data-driven, e.g. add a structure

    /** Additional language names that aren't covered by Qt locale as of [version] */
    static const struct {
        const char *abbrev;
        const char *name;
    } language_names[] = {
        {"szl", "Silesian"},
        {"pam", "Kapampangan"},
        {"la", "Latin"},
        {"eo", "esperanto"},
    };
    

    or more C++11ish

    static const std::map<std::string, std::string> language_names = {
        {"szl", "Silesian"},
        {"pam", "Kapampangan"},
        {"la", "Latin"},
        {"eo", "esperanto"},
    };
    
  27. in src/qt/optionsdialog.cpp:101 in 27a158617c
      97 | @@ -98,15 +98,39 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
      98 |      {
      99 |          QLocale locale(langStr);
     100 |  
     101 | -        /** check if the locale name consists of 2 parts (language_country) */
     102 | -        if(langStr.contains("_"))
     103 | +        if (locale.nativeLanguageName().length()==0) /* If locale name is an empty string, fix it manually. */
    


    laanwj commented at 11:00 AM on October 30, 2019:

    Nit: use isEmpty

    if (locale.nativeLanguageName().isEmpty())
    
  28. laanwj added the label Waiting for author on Oct 31, 2019
  29. laanwj commented at 11:50 AM on November 20, 2019: member

    I'm closing this; I don't think this is making any progress, and the amount of controversy it's created is not worth the scope of the change. Feel free to poke me if you want to re-start work on this, but I'm not sure this particular rabbit hole is worth getting into too much given the scope of this project. Might want to pursue an upstream change instead.

  30. laanwj closed this on Nov 20, 2019

  31. fanquake removed the label Waiting for author on Mar 11, 2020
  32. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 00:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me