Help to get a preferred language

Hello. I need get system language. I’ve found the related article.

I used this code snippet.

$ionicPlatform.ready(function () {
    navigator.globalization.getPreferredLanguage (
      function (language) {
        alert('language: ' + language.value + '\n');
      function () {
        alert('Error getting language\n');

I receive the error:

Uncaught TypeError: Cannot read property 'getPreferredLanguage' of undefined

Help me to get a user preffered language.

I needed to install plugin for Cordova.

cordova plugin add org.apache.cordova.globalization