Bug 376974 - sonnet should not just add regions to languages
Summary: sonnet should not just add regions to languages
Status: CONFIRMED
Alias: None
Product: frameworks-sonnet
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.29.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Martin Sandsmark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-27 09:39 UTC by Erik Quaeghebeur
Modified: 2021-01-02 14:40 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
screenshot of spellcheck dictionary selection box in Kate (12.03 KB, image/png)
2017-02-27 09:39 UTC, Erik Quaeghebeur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Quaeghebeur 2017-02-27 09:39:13 UTC
Created attachment 104241 [details]
screenshot of spellcheck dictionary selection box in Kate

I've detected this issue with Kate, but I am guessing it is a Sonnet issue:

In the spellcheck dictionary selection box, next to languages also countries are listed, even if the dictionary file does not contain a region (country) suffix. Furthermore, some language variants with a region have a specific name seemingly built-in to sonnet, but then again the country is listed next to it.

I think that in both cases, the country should not be listed, to not overload the selection box and make it easier to spot the language (variant) you want.

I attach a screenshot of the spellcheck dictionary selection box in Kate on my system. Below, I list the dictionary filenames (without .dic, .aff) and next to that the text I would think is appropriate in the selection box:

en_US ‘American English’ or ‘English (United States)’
en_AU ‘Australian English’ or ‘English (Australia)’
en_GB ‘Britisch English’ or ‘English (United Kingdom)’
en_CA ‘Canadian English’ or ‘English (Canada)’
en_ZA ‘South African English’ or ‘English (South Africa)’
nl_NL ‘Nederlands (Nederland)’ (this is fine, but nl should correspond to just ‘Nederlands’)
fr_Fr ‘français (France)’ (this is fine, but fr should correspond to just ‘français’)
fr-1990 ‘français [1990]’
fr-moderne ‘français [moderne]’
fr-ttsvars ‘français [ttsvars]’
Comment 1 Maximiliano Curia 2017-04-08 17:17:36 UTC
This is also reported in the Debian bug tracker as https://bugs.debian.org/801728
I think that a two or even three level selection of the dictionary (ala keyboard layout), would be easier to deal with.
Comment 2 Erik Quaeghebeur 2017-04-08 19:17:38 UTC
(In reply to Maximiliano Curia from comment #1)
> This is also reported in the Debian bug tracker as
> https://bugs.debian.org/801728
> I think that a two or even three level selection of the dictionary (ala
> keyboard layout), would be easier to deal with.

I do not think this is the same bug. I've reported here that Sonnet adds region names without there being one in the aff and dic file names.

That does not mean your bug does not have merit. I agree it does, a multi-level selection "language > region > variant" or "language > region/variant" would make things far more manageable. I'd suggest that you open a new bug and report its number here.
Comment 3 Waqar Ahmed 2019-11-24 12:10:41 UTC
This is not a bug, its how sonnet works. As I understand, if language country is disabled, it is going to be disabled for everything.
Comment 4 Erik Quaeghebeur 2019-11-24 19:43:48 UTC
(In reply to Waqar Ahmed from comment #3)
> This is not a bug, its how sonnet works.
It is a bug, i.e., how sonnet currently works is not correct.

> As I understand, if language country is disabled,
> it is going to be disabled for everything.
I do not understand what you are saying here.
Comment 5 Waqar Ahmed 2019-11-25 05:09:12 UTC
> It is a bug, i.e., how sonnet currently works is not correct.

Hi, apologies, going through the code again I realize that this is indeed a bug.

Sonnet uses 'iso codes' and depends on 'QLocale' to find out the language name and country. So for e.g., if you have a dictionary name 'fr-xxxx', Sonnet will take the `xxxx` away and mark it as the dictionary variant. Then sonnet will feed 'fr' (the iso code) into QLocale and ask it for language name(full lang name) and country name.

In the above mentioned case, the result will be "francais (France)". If you rename your dictionary to fr_CA, you will get a different result.

This does lead to some problems for e.g., with 'Arabic'. If the 'iso code' is 'ar', it always returns "Arabic - Egypt" or with 'en', English-United States.

The solution is quite simple. If the length of the iso code is less than 3, we ask QLocale for a country name.

I will fix it in downstream, QOwnNotes and see how it works out. If it doesn't give any problems, I will push the changes here.
Comment 6 Waqar Ahmed 2019-11-25 05:11:33 UTC
> If the length of the iso code is less than 3, we ask QLocale for a country name.

Correction: If the length of the iso code is greater than 3, we ask QLocale for a country name otherwise we don't.
Comment 7 Erik Quaeghebeur 2019-11-25 07:32:07 UTC
(In reply to Waqar Ahmed from comment #5)
> Sonnet uses 'iso codes' and depends on 'QLocale' to find out the language
> name and country. So for e.g., if you have a dictionary name 'fr-xxxx',
> Sonnet will take the `xxxx` away and mark it as the dictionary variant. Then
> sonnet will feed 'fr' (the iso code) into QLocale and ask it for language
> name(full lang name) and country name.
> 
> In the above mentioned case, the result will be "francais (France)". If you
> rename your dictionary to fr_CA, you will get a different result.
> 
> This does lead to some problems for e.g., with 'Arabic'. If the 'iso code'
> is 'ar', it always returns "Arabic - Egypt" or with 'en', English-United
> States.

I looked at QLocale <https://doc.qt.io/qt-5/qlocale.html> and indeed, they just throw in some ‘most appropriate’ country instead of leaving the country open (AnyCountry). That is just madness. This is an upstream, Qt bug, I would say.

> The solution is quite simple. If the length of the iso code is greater than 3,
> we ask QLocale for a country name.
> 
> I will fix it in downstream, QOwnNotes and see how it works out. If it
> doesn't give any problems, I will push the changes here.

Sounds like a good plan; thank you for your efforts. (I would consider it a workaround for the bad Qt behavior, but that'll be more difficult to correct.)
Comment 8 Waqar Ahmed 2019-11-25 10:52:01 UTC
Meanwhile, there are some missing iso codes in QLocale. So, dictionaries end up in the menu as 
- udm_RU

Most of 3 letter iso codes are missing in QLocale.
Comment 9 Erik Quaeghebeur 2021-01-02 14:40:33 UTC
(In reply to Waqar Ahmed from comment #5)
> I will fix it in downstream, QOwnNotes and see how it works out. If it
> doesn't give any problems, I will push the changes here.
Any update about this?

N.B.: Sonnet also does not even list languages for unknown country codes (e.g., nl_AA or nl_001).