Search code examples
delphitms-web-core

How do I get user's language from the system or browser in a TMS Web Core Website?


I'd like to know what language the user has set on his computer (system or browser).

How can I check or get the language with Delphi?


Solution

  • You can get the user's language with the window.navigator.language function from the Web unit.

    Here's a function:

    function GetSystemLanguage: String;
    begin
      Result := window.navigator.language;
    end;
    

    Here's a list of results that can come from window.navigator.language: List of ISO 639-1 language codes