Get the User Locale

If you have localized your app content into different languages, you can detect the locale of the user at runtime using the platform SDK or native Android methods. Then, use the locale to determine what language version of your app content you offer that user.

Get the Locale of the User for Rift Apps

You can get the locale of the logged in user with a call to the platform GetLoggedInUserLocale function.

For example:

    const char* locale = ovr_GetLoggedInUserLocale();
    // Do something depending on locale value.

The return value (locale in this example) is a language-country code string that conforms to BCP 47. This means you can expect a language subtag, a dash, and a country/region subtag. For example, “en-US” represents United States English.

Use the returned locale string to decide what language your app should display and use for this user.

Get the Locale of a User for Android Apps

For apps that run on Quest or Quest 2 devices, you get the locale of the user using the Android Locale.getDefault method.

The returned Locale object provides the ISO 639 alpha-2 or alpha-3 language code and the ISO 3166 alpha-2 country/region code as properties, and you can these to decide what language your app should display and use for this user.

See the Locale object in the Android documentation for more information.