Tries to determine the default locale settings and returns them as tuple (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") lets it use the default loc
(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE'))
| 536 | 'two strings -- language code, encoding.') from None |
| 537 | |
| 538 | def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')): |
| 539 | |
| 540 | """ Tries to determine the default locale settings and returns |
| 541 | them as tuple (language code, encoding). |
| 542 | |
| 543 | According to POSIX, a program which has not called |
| 544 | setlocale(LC_ALL, "") runs using the portable 'C' locale. |
| 545 | Calling setlocale(LC_ALL, "") lets it use the default locale as |
| 546 | defined by the LANG variable. Since we don't want to interfere |
| 547 | with the current locale setting we thus emulate the behavior |
| 548 | in the way described above. |
| 549 | |
| 550 | To maintain compatibility with other platforms, not only the |
| 551 | LANG variable is tested, but a list of variables given as |
| 552 | envvars parameter. The first found to be defined will be |
| 553 | used. envvars defaults to the search path used in GNU gettext; |
| 554 | it must always contain the variable name 'LANG'. |
| 555 | |
| 556 | Except for the code 'C', the language code corresponds to RFC |
| 557 | 1766. code and encoding can be None in case the values cannot |
| 558 | be determined. |
| 559 | |
| 560 | """ |
| 561 | |
| 562 | return _getdefaultlocale(envvars) |
| 563 | |
| 564 | |
| 565 | def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')): |
no test coverage detected
searching dependent graphs…