# How can I make a widget for language changing in BTT?

**URL:** <https://community.folivora.ai/t/how-can-i-make-a-widget-for-language-changing-in-btt/15878>\
**Category:** Configuration Help & General Discussion\
**Created:** [May 6, 2020, 11:42am UTC](https://community.folivora.ai/t/how-can-i-make-a-widget-for-language-changing-in-btt/15878 "2020-05-06T11:42:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Mak](https://community.folivora.ai/user_avatar/community.folivora.ai/ryan_mak/32/28456_2.png) [@Ryan\_Mak](https://community.folivora.ai/u/Ryan_Mak)\
**Post date:** [May 6, 2020, 11:42am UTC](https://community.folivora.ai/t/how-can-i-make-a-widget-for-language-changing-in-btt/15878/1 "2020-05-06T11:42:52Z")

</div>

I have a few languages on my computer and it would be helpful if there could be a language changer widget.

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [May 6, 2020, 1:40pm UTC](https://community.folivora.ai/t/how-can-i-make-a-widget-for-language-changing-in-btt/15878/2 "2020-05-06T13:40:18Z")

</div>

The Spelling checker you mean, the one you can find in System Settings → Keyboard → Text?

Well, I made a shell script that checks for it:

```
#!/bin/sh

MULTI=`defaults read -g NSSpellCheckerAutomaticallyIdentifiesLanguages`

if [$MULTI -eq 1]; then echo 🌐
else
    MULTI=`defaults read -g NSPreferredSpellServerLanguage` 
    if [$MULTI = fr]; then echo 🇫🇷
    elif [$MULTI = de]; then echo 🇩🇪
    elif [$MULTI = it]; then echo 🇮🇹
    elif [$MULTI = en]; then echo 🇺🇸
    elif [$MULTI = ro_RO]; then echo 🇷🇴
    elif [$MULTI = Romanian]; then echo 🇷🇴
    else echo ❔
    fi
fi

```

to change the language to Automatic by language run this script:

```
#!/bin/sh

MULTI=`defaults write -g NSSpellCheckerAutomaticallyIdentifiesLanguages 1`

```

to change the language to English run this script:

```
#!/bin/sh

MULTI=`defaults write -g NSSpellCheckerAutomaticallyIdentifiesLanguages 0; defaults write -g NSPreferredSpellServerLanguage en`

```

to change the language to French run this script:

```
#!/bin/sh

MULTI=`defaults write -g NSSpellCheckerAutomaticallyIdentifiesLanguages 0; defaults write -g NSPreferredSpellServerLanguage fr`

```

Etc. Basically replace the last two letters to what you get if you run `defaults read -g NSPreferredSpellServerLanguage` in the Terminal.

It kinda works, but is a bit buggy sometimes. Not sure wether this isn't due to macOS though.

---

<div class="post-metadata">

**Author:** ![Ryan\_Mak](https://community.folivora.ai/user_avatar/community.folivora.ai/ryan_mak/32/28456_2.png) [@Ryan\_Mak](https://community.folivora.ai/u/Ryan_Mak)\
**Post date:** [May 6, 2020, 1:45pm UTC](https://community.folivora.ai/t/how-can-i-make-a-widget-for-language-changing-in-btt/15878/3 "2020-05-06T13:45:33Z")

</div>

How about for languages that have various input methods? Is there a two letter code for those?

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [May 6, 2020, 1:49pm UTC](https://community.folivora.ai/t/how-can-i-make-a-widget-for-language-changing-in-btt/15878/4 "2020-05-06T13:49:28Z")

</div>

Set the language you want to know in the system settings, then run this terminal command:

```
defaults read -g NSPreferredSpellServerLanguage

```

You'll get a result such as **en** for "Automatic by Language", **de** for German, my self added language Romanian returns **ro\_RO**. It's this result you have to paste at the end of the commands (attention, it's capital sensitive).

---

<div class="post-metadata">

**Author:** ![Ryan\_Mak](https://community.folivora.ai/user_avatar/community.folivora.ai/ryan_mak/32/28456_2.png) [@Ryan\_Mak](https://community.folivora.ai/u/Ryan_Mak)\
**Post date:** [May 6, 2020, 1:51pm UTC](https://community.folivora.ai/t/how-can-i-make-a-widget-for-language-changing-in-btt/15878/5 "2020-05-06T13:51:41Z")

</div>

Thanks

---

<div class="post-metadata">

**Author:** ![Ryan\_Mak](https://community.folivora.ai/user_avatar/community.folivora.ai/ryan_mak/32/28456_2.png) [@Ryan\_Mak](https://community.folivora.ai/u/Ryan_Mak)\
**Post date:** [May 6, 2020, 1:53pm UTC](https://community.folivora.ai/t/how-can-i-make-a-widget-for-language-changing-in-btt/15878/6 "2020-05-06T13:53:06Z")

</div>

Changing the language doesn't seem to help though. It just returns "en" as that is my system default

---

<div class="post-metadata">

**Author:** ![111139](https://community.folivora.ai/user_avatar/community.folivora.ai/111139/32/13082_2.png) [@111139](https://community.folivora.ai/u/111139)\
**Post date:** [June 13, 2020, 3:30pm UTC](https://community.folivora.ai/t/how-can-i-make-a-widget-for-language-changing-in-btt/15878/7 "2020-06-13T15:30:18Z")

</div>

> [@Russian review on BetterTouchTool](https://community.folivora.ai/t/russian-review-on-bettertouchtool/16530/3):
>
> [language.bttpreset](https://community.folivora.ai/uploads/short-url/b1kp6yf4hBBEzIU9kUduuASZipB.bttpreset) (15.8 KB) ru-en [language-ru-en-fr-ger.bttpreset](https://community.folivora.ai/uploads/short-url/pbAsAItQ3j2gMPF8CxsLUUBNF8E.bttpreset) (15.9 KB) add language changes of input languages rus/en with icon in button add more language use NeonTouchBar for language switch

сделал виджет для переключения языка

---

<div class="post-metadata">

**Author:** ![Dongpogoy](https://community.folivora.ai/letter_avatar_proxy/v4/letter/d/7993a0/32.png) [@Dongpogoy](https://community.folivora.ai/u/Dongpogoy)\
**Post date:** [March 12, 2022, 11:14pm UTC](https://community.folivora.ai/t/how-can-i-make-a-widget-for-language-changing-in-btt/15878/8 "2022-03-12T23:14:13Z")

</div>

111139's solution worked out for me. The core of the bttpreset file is to create a trigger action to hit a keyboard shortcut to change the language. The optional Mac script displays an icon matches the current selected language.

---- Apple Script ----

```auto
set activeKbdLayout to my getActiveKeyboardLayout()
on getActiveKeyboardLayout()
  set plistPath to "~/Library/Preferences/com.apple.HIToolbox.plist"
  try
    do shell script "defaults read " & plistPath & " dummy"
  end try

  tell application "System Events"
    repeat with pli in property list items of ¬
      property list item "AppleSelectedInputSources" of ¬
      property list file plistPath
      try
        return value of property list item "KeyboardLayout Name" of pli
      end try
    end repeat
  end tell
  return "Unknown"
end getActiveKeyboardLayout

if activeKbdLayout is "U.S." then
  return "🇺🇸"
else if activeKbdLayout is "Russian" then
  return "🇷🇺"
else if activeKbdLayout is "Unknown" then
  return "🏁"
else
  return "🏁"
end if

```
