Synology DSM: Multilingual 3rd Party Packages

This is how to detect the language which the Synology DSM ExtJS v3.4 Desktop currently displays “on screen”. In order to integrate 3rd party packages properly with the language currently displayed to the user.

I’d required a DS712+ or DS412+ but got a DS411slim with ARMv5TE CPU, which is quite a toy. Marvell Kirkwood, the Aramada 300 series seems to be quite consumer-orientated in general; The least required for serious Linux is ARMv7 platform — more like the Marvell Armada XP, in order to run Ubuntu for ARM.

Just gave up because Synology doesn’t provide essential DSM documentation or any real developer support. Nothing against closed source-code, but such proprietary Linux distributions are simply too time-consuming to be effective to work with in any way. Also – after being sold consumer-electronics, they didn’t won’t to change it to something more adequate for a web-developer.

function user_lang($username='admin'){
   $json='/usr/syno/etc/preference/'.$username.'/usersettings';
   if(file_exists($json)){
      $obj=json_decode(file_get_contents($json));
      return $obj->Personal->lang;
    }
 }

function user_name(){
   $username='';
   putenv('HTTP_COOKIE='.$_SERVER['HTTP_COOKIE']);
   putenv('REMOTE_ADDR='.$_SERVER['REMOTE_ADDR']);
   exec('/usr/syno/synoman/webman/modules/authenticate.cgi', $username, $retval);
   if($retval==0 && $username!=''){return $username[0];}else{return false;}
}