Can the Google Apps Script web application get the user language and time zone?

Is there any possibility for a GAS published as a web application running under the active user ID and using the Ui Service for the user interface to get the preferred language and time zone of the user? Session.getActiveUser() works, but you only get email Session.getActiveUser().getEmail() .
Session.getTimeZone() returns the time zone of the script, not the user.

Could there be a trick to get a web browser id string with language preference?

+4
source share
2 answers

Session.getActiveUserLocale () was introduced in 2014 to provide this capability.

+2
source

This is a very interesting question. I think the short answer is that there is no good way, and you should ask users about your language / language.

I see no way to do this on the server side using the APIs that you already discussed. However, I was thinking maybe there is a sensible way to do this on the client side and send it to the server using the google.script API after getting the locale information from the navigator.language JS call.

Unfortunately, since the HTML / JS that you have in your web application is sanitized for security through Caja , only part of the normal <properties href = "https://developer.mozilla.org/en-US/ docs / DOM / window.navigator "rel =" nofollow "> window.navigator. It seems that the only useful features are userAgent and the platform. The language seems harmless enough for disclosure, so it’s worth writing a request to Tracking problems .

+2
source

Source: https://habr.com/ru/post/1434239/


All Articles