Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes Dutch language file default to U.S. keyboard layout #1954

Merged
merged 1 commit into from Sep 24, 2022

Conversation

Wengier
Copy link
Sponsor Collaborator

@Wengier Wengier commented Sep 22, 2022

This intends to solve #1951 as reported by @rderooy by making the Dutch language file default to the U.S. keyboard layout, since as mentioned in the issue Dutch keyboard layouts are very rarely used in the Netherlands.

@Wengier Wengier self-assigned this Sep 22, 2022
@Wengier Wengier linked an issue Sep 22, 2022 that may be closed by this pull request
3 tasks
@Wengier Wengier mentioned this pull request Sep 22, 2022
3 tasks
@rderooy
Copy link
Collaborator

rderooy commented Sep 22, 2022

I did a test with this patch, and indeed it keeps the US layout. But it also causes this error in the log:

LAYOUT: Failed loading codepage 850 for detected language nl

In addition to testing with nl_NL.UTF-8 as locale, I tested with:

LANG=nl_BE.UTF-8 dosbox

This is the Belgium Dutch (Flemish) locale. This also came up with a US layout, which is actually not correct as it should use the Belgium layout.

For those not in the know, Belgium has three locales. nl_BE.UTF-8, fr_BE.UTF-8 and de_BE.UTF-8. Basically Dutch, French and German. But all 3 use the same French-style keyboard layout (AZERTY).

@rderooy
Copy link
Collaborator

rderooy commented Sep 22, 2022

Some further testing reveals more issues with keyboard layouts.

Switzerland has 4 locales and 2 keyboard layouts (Swiss-German and Swiss-French). When starting with
LANG=de_CH.UTF-8 dosbox it gives a German keyboard layout, instead of Swiss-German (keyb sg), and a similar issue will occur with LANG=fr_CH.UTF-8 dosbox which will give a French keyboard, instead of Swiss-French (keyb sf).

Swiss-Italian (it_CH) should default to the Swiss-French keyboard, and Swiss-Romansh (rm_CH) should default to the Swiss-German keyboard.

And then you may think that a country as tiny as Luxembourg would be easy. It only has 2 locales (fr_LU and de_LU). But it does not have it's own keyboard layout. Instead it uses Belgium, French and German keyboards in addition to Swiss-French keyboards commonly found in schools and government institutions. Try to guess the layout...

@kcgen
Copy link
Member

kcgen commented Sep 22, 2022

Currently the chunk of code that parses LANG= only takes the first-two letters (the language component), and skips the rest. This was a deliberate choice back when LANG's only purpose was load one of our 5 translations (de, es, it, po, ru).

This should be expanded into handling both the language and country components, and then flowed into the layout and other settings on start-up.

@kcgen
Copy link
Member

kcgen commented Sep 22, 2022

Some further testing reveals more issues with keyboard layouts.

Switzerland has 4 locales and 2 keyboard layouts (Swiss-German and Swiss-French). When starting with LANG=de_CH.UTF-8 dosbox it gives a German keyboard layout, instead of Swiss-German (keyb sg), and a similar issue will occur with LANG=fr_CH.UTF-8 dosbox which will give a French keyboard, instead of Swiss-French (keyb sf).

Swiss-Italian (it_CH) should default to the Swiss-French keyboard, and Swiss-Romansh (rm_CH) should default to the Swiss-German keyboard.

And then you may think that a country as tiny as Luxembourg would be easy. It only has 2 locales (fr_LU and de_LU). But it does not have it's own keyboard layout. Instead it uses Belgium, French and German keyboards in addition to Swiss-French keyboards commonly found in schools and government institutions. Try to guess the layout...

@rderooy , right now only the language is fetched from the LANG= variable.

If we get the second country code from the LANG= as well, how should this play into these conf settings:

[dos]
#               country: Set DOS country code which will affect country-specific
#                        information such as date, time, and decimal formats.
#                        If set to 0, the country code corresponding to the
#                        selected keyboard layout will be used.
#        keyboardlayout: Language code of the keyboard layout (or none).

country               = 0
keyboardlayout        = auto

I think we want to follow the general software approach of "near/specific" variables trump "distant/general" variables.

So if the conf's country and keyboardlayout are defaults, then we try to derive these from the more general LANG env variable.

But if country and/or layout are customized inside the conf, then those should take priority over the LANG.

@kcgen kcgen added translation Issues related to translations backport Important fixes that should be backported labels Sep 23, 2022
@rderooy
Copy link
Collaborator

rderooy commented Sep 23, 2022

Relying on the LANG variable to "guess" the keyboard layout is very much hit and miss. A few ways to check keyboard layout on Linux that I am aware of.

This seems to return the current keyboard layout, but requires X11 (or XWayland) to be present

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us

This uses systemd, but returns the default "system" layout, and may not reflect the currently set layout for the user.

$ localectl
   System Locale: LANG=en_GB.UTF-8
       VC Keymap: us-euro
      X11 Layout: us,us
     X11 Variant: euro,intl
$ cat /etc/vconsole.conf 
KEYMAP="us-euro"
FONT="eurlatgr"

@Wengier Wengier force-pushed the ww/nl-default-us branch 3 times, most recently from 0b7999c to e35dcc5 Compare September 24, 2022 04:43
@Wengier
Copy link
Sponsor Collaborator Author

Wengier commented Sep 24, 2022

@rderooy The log message LAYOUT: Failed loading codepage 850 for detected language nl will also not be shown with the updated code. Other issue(s) mentioned above probably go to separate PRs.

@kcgen
Copy link
Member

kcgen commented Sep 24, 2022

Looks great, @Wengier!

@kcgen kcgen merged commit c438d8e into main Sep 24, 2022
@kcgen kcgen deleted the ww/nl-default-us branch October 1, 2022 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Important fixes that should be backported translation Issues related to translations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autoselect of Dutch keyboard layout
3 participants