Skip to main content
2 of 2
added 2 characters in body

Looks like language field is not available via $User global variable. Here is a knowledge article about it

https://help.salesforce.com/apex/HTViewSolution?id=000205451&language=en_US

I checked for the available values for user and Language is not one of them. However there are other ways to implement this

  1. Use Remote object and query the languageISOCode from there

    < apex:page>

     <  apex:remoteObjects jsNamespace="RemoteObjectModel">
       <  apex:remoteObjectModel name="User" jsShorthand="userRec"
             fields="Id,LanguageLocaleKey">
         </apex:remoteObjectModel>
     </apex:remoteObjects>
    
     <input type="button" onclick="fetchUsers();" value="MyButton"/>
    
     <script>
         var fetchUsers = function(){
             // Create a new Remote Object
             var ur = new RemoteObjectModel.userRec();
             var userID = '{!$user.id}';
             // Use the Remote Object to query for 10 warehouse records
             ur.retrieve({where: {Id: {eq:userID}}, limit: 10 }, function(err, records, event){
                 if(err) {
                     alert(err.message);
                 }
                 else {
                     console.log(records[0].get('LanguageLocaleKey'));
                 }
             });
         };
     </script>
    

    </apex:page>

  2. Use SFDC JS Toolkit to query it (JS Wrapper for APIs). Connection.js