Page 1 of 2

Keyboard language

Posted: Sat Jun 18, 2022 8:20 pm
by marksmithhfx
Hi, does anyone know if you can detect the users preferred language for desktop apps? I'd like to know if the user is using British/Canadian/United States english.

Thanks
Mark

Re: Keyboard language

Posted: Sat Jun 18, 2022 8:30 pm
by richmond62
Would that be on MacOS, Windows or Linux, as I suspect the answer in each case may be different?

Re: Keyboard language

Posted: Sun Jun 19, 2022 8:43 am
by marksmithhfx
richmond62 wrote:
Sat Jun 18, 2022 8:30 pm
Would that be on MacOS, Windows or Linux, as I suspect the answer in each case may be different?
Good question Richmond, MacOS

Re: Keyboard language

Posted: Sun Jun 19, 2022 10:45 am
by SWEdeAndy
Hi Mark! Would any of this get the result you need?

To get preferred language:

Code: Select all

put "defaults read -g AppleLanguages | sed -n " & quote & "2p" & quote & " | tr -d ," into tLine
put shell(tLine)
To get current keyboard layout:

Code: Select all

put "defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | egrep -w 'KeyboardLayout Name' |sed -E 's/^.+ = \" & quote & "?([^\" & quote & "]+)\" & quote & "?;$/\1/'" into tLine
put shell(tLine)

Re: Keyboard language

Posted: Sun Jun 19, 2022 11:49 am
by jmburnod
Hi All,
What about Info.plist file ?
Edit: OK doesn't work on windows
Best regards
Jean-Marc

Re: Keyboard language

Posted: Sun Jun 19, 2022 2:18 pm
by richmond62
You could ask the end-user to press 3 or 4 keys and compare keyUps against a lookup table.

Re: Keyboard language

Posted: Thu Jun 23, 2022 10:55 am
by richmond62
Screen Shot 2022-06-23 at 12.54.36 PM.png
-
I wonder, if down in the undergrowth?
-
Playing around with RevMedia 4 on MacOS 10.7.4 as I tend to do in my lunch break
I can see Keyboard synching at work.
-
Screen Shot 2022-06-23 at 1.03.59 PM.png
-
Keyboard synching got turned off . . .

I wonder if there is an easy way to turn it on again programmatically?

Two questions:

1. Why was it not preserved as an option?

2. Why, whenever I encounter the word 'modern' do I cringe?

Re: Keyboard language

Posted: Thu Jun 23, 2022 11:11 am
by richmond62
HyperCard broke several moulds and was fairly iconoclastic,

and that was its greatest strength . . .

I wonder why LiveCode seems to have lost sight of that, and is falling
over backwards to:

be "inline with modern practice" . . . ?

A great pity really.

Re: Keyboard language

Posted: Thu Jun 23, 2022 3:19 pm
by marksmithhfx
SWEdeAndy wrote:
Sun Jun 19, 2022 10:45 am
Hi Mark! Would any of this get the result you need?

To get preferred language:

Code: Select all

put "defaults read -g AppleLanguages | sed -n " & quote & "2p" & quote & " | tr -d ," into tLine
put shell(tLine)
To get current keyboard layout:

Code: Select all

put "defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | egrep -w 'KeyboardLayout Name' |sed -E 's/^.+ = \" & quote & "?([^\" & quote & "]+)\" & quote & "?;$/\1/'" into tLine
put shell(tLine)
Thank you Andreas, they both work perfectly. The first returned "en-CA" on one of my laptops and "en-GB" on the other. The second one returned "British" for both of the them (and that is correct since I started using the GB keyboard on both). My need was to see if the user preferred GB english spelling ("colour", "favourites", "grey") or North American english spelling ("color", "favorites", "gray") and this will do it.

Cheers,
Mark

Re: Keyboard language

Posted: Thu Jun 23, 2022 3:31 pm
by marksmithhfx
jmburnod wrote:
Sun Jun 19, 2022 11:49 am
Hi All,
What about Info.plist file ?
Edit: OK doesn't work on windows
Best regards
Jean-Marc
Hi J-M, I'm not sure. How does one investigate info.plist?

Thanks
Mark

Re: Keyboard language

Posted: Sun Jun 26, 2022 6:41 pm
by jmburnod
Hi Mark
Sorry i missed your post. :oops:
info.plist file is generated when you compile an app for ios.
You may open it with textedit and change localization item.
LocalizationInfoPlist.png
Kind regards
Jean-Marc

Re: Keyboard language

Posted: Sun Jun 26, 2022 11:52 pm
by FourthWorld
richmond62 wrote:
Thu Jun 23, 2022 11:11 am
HyperCard broke several moulds and was fairly iconoclastic,

and that was its greatest strength . . .

I wonder why LiveCode seems to have lost sight of that, and is falling
over backwards to:

be "inline with modern practice" . . . ?

A great pity really.
HyperCard supported keyboard syncing?

Re: Keyboard language

Posted: Mon Jun 27, 2022 7:26 am
by richmond62
That I don't know.

But that was not the point of that remark.

Re: Keyboard language

Posted: Mon Jun 27, 2022 12:15 pm
by marksmithhfx
jmburnod wrote:
Sun Jun 26, 2022 6:41 pm
Hi Mark
Sorry i missed your post. :oops:
No worries J-M. I usually only check in every few days anyway (never did discover if there was a way to be notified in email if a reply is posted to a post... is there a way to turn that on?).

This time I was actually developing a macOS app so I'm not sure if a plist is developed for that? Anyway, the terminal commands Andreas posted worked perfectly for the case I had in mind.

Cheers,
Mark

Re: Keyboard language

Posted: Mon Jun 27, 2022 2:18 pm
by richmond62
macOS app bundles usually contain a plist:
-
Screen Shot 2022-06-27 at 4.17.01 PM.png