#!/usr/bin/env python3 # detect_locale.py # # Author: Intel A80486DX2-66 # License: Creative Commons Zero 1.0 Universal or Unlicense # SPDX-License-Identifier: CC0-1.0 OR Unlicense from typing import Optional from os import environ, name as os_name if os_name == "nt": from ctypes import windll from locale import windows_locale def detect_locale() -> Optional[str]: if os_name == "posix": return environ["LANG"] if os_name == "nt": return windows_locale[windll.kernel32.GetUserDefaultUILanguage()] return None if __name__ == "__main__": print(detect_locale())