Get System Language [JS1]

A JavaScript one-liner to find out the language of your device


Description

A single line of JavaScript to find out what language your system uses*. This is somewhat slower than my System Language shortcut, but its simplicity is unbeatable.

(*) Thanks to @arifbuti (see feedback below) I found out that the Shortcuts app has its own language setting (at least in iOS 14), and that's what this shortcut normally detects. To detect the real system language you must run this snippet from an automation.

Don't download the shortcut

If you just want the code, there's no need to download the shortcut. Copy this and paste it in a "URL" action:

data:text/html,<script>document.write(navigator.language.substr(0,2))</script>

Add a "Get File of Type" with type com.apple.webarchive below, and its output will be the two-letter ISO 639 language code (e.g. "en" for English, and "es" for Spanish).

I use "Get File of Type" instead of "Get Contents of Webpage" to avoid that the user is misleading told that the shortcut uses Safari.


Latest Release Notes

1.0.0 - Oct. 2, 2020, 2:03 a.m.

First public version