In my projects I am using AD-Internal, and at Client startup I try to set the user’s preferred Language.
One thing that I have noticed is that in order to retrieve a not None value for a user’s Language I have to manually select a language first.
DEFAULT_LANGUAGE = 'en_US' # Get the user from SSO profile: user = system.user.getUser("AD-Internal_Auth", system.security.getUsername()) if user is None: system.util.setLocale(DEFAULT_LANGUAGE) elif user.getOrDefault(user.Language) is not None: system.util.setLocale(user.getOrDefault(user.Language)) else: system.util.setLocale(DEFAULT_LANGUAGE)
All of the users retrieved from AD have “English (United States)” as their language, but when I run the script above, user.getOrDefault(user.Language) returns None. It’s not until I edit the user that it does return the user’s language.
I expect that getOrDefault would return the Default value as documented, but it returns None instead.
Is there something I am missing?
Should I be setting the Default language somewhere in Ignition’s configuration?
Currently I have a workaround in place; I am just curious about the expected behavior versus reality.