Skip to content

Support locale module on Android #135753

Open
@mhsmith

Description

@mhsmith

Migrated from chaquo/chaquopy#1150:


From beeware/toga#2562:

Hello, how can I recognize the current language with locale.getlocale()?
When i try it on android, it only returns ('en_US', 'UTF-8'), even if default language was set to an other language.

I don't think Android sets any of the standard LC_... environment variables, probably because it supports changing the locale within the lifetime of a single process. Instead, it provides an Android-specific API:

context.getResources().getConfiguration().getLocales().get(0)

This will return a string in the form en_US, which can be passed to locale.setlocale.

The difficult part is getting a reference to the context object. For details, see #90371 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-androidstdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions