Keyboard language
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Keyboard language
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
Thanks
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- Livecode Opensource Backer
- Posts: 9385
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Keyboard language
Would that be on MacOS, Windows or Linux, as I suspect the answer in each case may be different?
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: Keyboard language
Good question Richmond, MacOSrichmond62 wrote: ↑Sat Jun 18, 2022 8:30 pmWould that be on MacOS, Windows or Linux, as I suspect the answer in each case may be different?
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- VIP Livecode Opensource Backer
- Posts: 261
- Joined: Sat Aug 16, 2008 9:48 am
- Location: Stockholm, Sweden
- Contact:
Re: Keyboard language
Hi Mark! Would any of this get the result you need?
To get preferred language:
To get current keyboard layout:
To get preferred language:
Code: Select all
put "defaults read -g AppleLanguages | sed -n " & quote & "2p" & quote & " | tr -d ," into tLine
put shell(tLine)
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)
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Keyboard language
Hi All,
What about Info.plist file ?
Edit: OK doesn't work on windows
Best regards
Jean-Marc
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
-
- Livecode Opensource Backer
- Posts: 9385
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Keyboard language
You could ask the end-user to press 3 or 4 keys and compare keyUps against a lookup table.
-
- Livecode Opensource Backer
- Posts: 9385
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Keyboard language
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.
- -
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?
-
- Livecode Opensource Backer
- Posts: 9385
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Keyboard language
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.
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.
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: Keyboard language
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.SWEdeAndy wrote: ↑Sun Jun 19, 2022 10:45 amHi Mark! Would any of this get the result you need?
To get preferred language:To get current keyboard layout:Code: Select all
put "defaults read -g AppleLanguages | sed -n " & quote & "2p" & quote & " | tr -d ," into tLine put shell(tLine)
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)
Cheers,
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: Keyboard language
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
Targets: Mac, iOS
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Keyboard language
Hi Mark
Sorry i missed your post.
info.plist file is generated when you compile an app for ios.
You may open it with textedit and change localization item. Kind regards
Jean-Marc
Sorry i missed your post.
info.plist file is generated when you compile an app for ios.
You may open it with textedit and change localization item. Kind regards
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9836
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Keyboard language
HyperCard supported keyboard syncing?richmond62 wrote: ↑Thu Jun 23, 2022 11:11 amHyperCard 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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Livecode Opensource Backer
- Posts: 9385
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Keyboard language
That I don't know.
But that was not the point of that remark.
But that was not the point of that remark.
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: Keyboard language
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
Targets: Mac, iOS
-
- Livecode Opensource Backer
- Posts: 9385
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Keyboard language
macOS app bundles usually contain a plist:
-
-