# Script to change system language on Mac

Your macOS device may have been configured to display the language of the region where you purchased it. However, you can choose a different language so that the users view the menus and dialogues appearing in the system in their preferred language. Here’s a custom script to change the system language on macOS devices. Use Hexnode’s [Execute Custom Script](https://www.hexnode.com/mobile-device-management/help/how-to-run-scripts-on-mac-using-hexnode-mdm/) action to execute the scripts.

 Disclaimer:The Sample Scripts provided below are adapted from third-party Open-Source sites.

 

Change default system language
------------------------------

First, fetch the languages supported on the device, executing the following command on the device displays all languages supported by it.

Script to fetch supported languages

languagesetup 

   1

  languagesetup 

   

 

  

You can then execute the script to change the system language to any preferred language supported on the device. Here in this script, the `defaults write` command takes in two parameters, a primary language (de) and a secondary language (en), as [language designators](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/LanguageandLocaleIDs/LanguageandLocaleIDs.html) and then changes the system language to the primary language. If the primary language is not supported, the secondary language is used as a system language. You can specify the primary and secondary languages as per your choice in the `defaults write` command. The script takes effect for the currently logged-in user.

Script to change system language

\#!/bin/bash CURRENT\_USER=`stat -f%Su /dev/console` #Change system language sudo su $CURRENT\_USER -c "defaults write -g AppleLanguages -array de en " 

   1

2

3

4

5

6

7

8

9

10

11

  \#!/bin/bash 

CURRENT\_USER=`stat -f%Su /dev/console`

\#Change system language 

sudo su $CURRENT\_USER -c "defaults write -g AppleLanguages -array de en " 

   

 

  

 Notes:- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.