Keyboard language

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Keyboard language

Post by marksmithhfx » Sat Jun 18, 2022 8:20 pm

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Keyboard language

Post by richmond62 » 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?

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: Keyboard language

Post by marksmithhfx » Sun Jun 19, 2022 8:43 am

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Keyboard language

Post by SWEdeAndy » 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)
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Keyboard language

Post by jmburnod » 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
Last edited by jmburnod on Sun Jun 19, 2022 3:05 pm, edited 1 time in total.
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Keyboard language

Post by richmond62 » Sun Jun 19, 2022 2:18 pm

You could ask the end-user to press 3 or 4 keys and compare keyUps against a lookup table.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Keyboard language

Post by richmond62 » Thu Jun 23, 2022 10:55 am

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?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Keyboard language

Post by richmond62 » 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.

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: Keyboard language

Post by marksmithhfx » Thu Jun 23, 2022 3:19 pm

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: Keyboard language

Post by marksmithhfx » Thu Jun 23, 2022 3:31 pm

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Keyboard language

Post by jmburnod » Sun Jun 26, 2022 6:41 pm

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
https://alternatic.ch

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9836
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Keyboard language

Post by FourthWorld » Sun Jun 26, 2022 11:52 pm

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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Keyboard language

Post by richmond62 » Mon Jun 27, 2022 7:26 am

That I don't know.

But that was not the point of that remark.

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: Keyboard language

Post by marksmithhfx » Mon Jun 27, 2022 12:15 pm

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Keyboard language

Post by richmond62 » Mon Jun 27, 2022 2:18 pm

macOS app bundles usually contain a plist:
-
Screen Shot 2022-06-27 at 4.17.01 PM.png

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”