Andrey Bushman
Andrey Bushman

Reputation: 12506

How can I get current localization of Linux through C?

How can I get current localization (ru-RU, en-US, en-GB, e.t.c.) of Linux through C?

Thank you.

Upvotes: 0

Views: 517

Answers (2)

Nicola Coretti
Nicola Coretti

Reputation: 2685

Have a look at the nl_langinfo and the localeconv man pages.

How to search for subroutines and/or system calls on a Unix system:

  • query via apropos. e.g.: apropos locale
  • look for results which reference man section 2 (system calls) or man section 3. (subroutines). e.g. on mac:

    querylocale(3)           - Get locale name for a specified category
    setlocale(3)             - natural language formatting for C
    
  • have a look at the man pages

Upvotes: 3

Michael F
Michael F

Reputation: 40829

On a POSIX-compliant system, setlocale(LC_CTYPE, NULL); would return the name of the locale currently selected for category LC_CTYPE.

Upvotes: 4

Related Questions