LocaleInfo QML Type

Provides locale properties for translation purposes. More...

Import Statement: import ArcGIS.AppFramework 1.0

Properties

Signals

Detailed Description

The LocaleInfo component provides access to additional locale properties. It also provides a way to map the system locale name to the Esri standard locale name, useful in contexts such as OAuth signin dialogs.

This sample provides a text box to declare a locale code, which will then populate a table with a number of LocaleInfo properties. It also demonstrates a potential usage of the component with OAuth signin.

Item {
    property string localeName
    property var locale
    property string oauthUrlFormat: "https://www.arcgis.com/sharing/rest/oauth2/authorize?client_id=arcgisonline&redirect_uri=http://www.arcgis.com&response_type=token&locale=%1"
    property url oauthUrl

    Component.onCompleted: {
        localeName = Qt.locale().name;
    }

        onLocaleNameChanged: {
        locale = Qt.locale(localeName);
        updateTimer.start();
    }

        LocaleInfo {
        id: localeInfo
        name: localeName
        onLocaleChanged: {
            localeInfoModel.update(localeInfo);
            oauthUrl = oauthUrlFormat.arg(esriName);
            if (oauthTab.item) {
                oauthTab.item.url = oauthUrl;
            }
        }
    }

        Timer {
        id: updateTimer
        interval: 10
        repeat: false
        onTriggered: {
            if (localeInfoTab.item) {
                localeInfoTab.item.resizeColumnsToContents();
            }
        }
    }

        ListModel {
        id: localeInfoModel
        function update(localeInfo) {
            clear();
            add("name",                 localeInfo.name);
            add("ietfName",             localeInfo.ietfName);
            add("esriName",             localeInfo.esriName);
            add("languageName",         localeInfo.languageName);
            add("languageCode",         localeInfo.languageCode);
            add("countryName",          localeInfo.countryName);
            add("countryCode",          localeInfo.countryCode);
            add("scriptName",           localeInfo.scriptName);
            add("scriptCode",           localeInfo.scriptCode);
        }
        function add(name, value) {
            append({
                       name: name,
                       value: value.toString()
                   });
        }
    }

    ColumnLayout {
        anchors {
            fill: parent
            margins: 5 * AppFramework.displayScaleFactor
        }
        spacing: 5 * AppFramework.displayScaleFactor
        RowLayout {
            Layout.fillWidth: true
            Text {
                text: "Locale search"
            }
            TextField {
                id: localeField
                Layout.fillWidth: true
                text: localeName
                placeholderText: "Locale"
                onEditingFinished: {
                    localeName = text;
                }
                function update(name) {
                    text = name;
                    editingFinished();
                }
            }
        }
        TabView {
            Layout.fillWidth: true
            Layout.fillHeight: true
            Tab {
                id: localeInfoTab
                title: "LocaleInfo"
                TableView {
                    model: localeInfoModel
                    Component.onCompleted: {
                        updateTimer.start();
                    }
                    TableViewColumn {
                        role: "name"
                        title: "Property"
                    }
                    TableViewColumn {
                        role: "value"
                        title: "Value"
                    }
                }
            }
            Tab {
                id: oauthTab
                title: "Sign In Page"
                WebView {
                    Component.onCompleted: {
                        url = oauthUrl;
                    }
                }
            }
        }
    }
}

Property Documentation

[read-only] countryCode : string

Returns the locale's two-character country code.


[read-only] countryName : string

Returns the name of the locale's country.


[read-only] esriName : string

Returns the standard two-character code used by Esri for this language.

If the language being used is not Esri-supported, returns 'en'. These unsupported languages can still be used within in your app, but are not supported by ArcGIS Online.


[read-only] ietfName : string

Returns the IETF standard language and region code for this language.


[read-only] languageCode : string

Returns the two to three-character code denoting the language being used.


[read-only] languageName : string

Returns the name of the language being used.


name : string

Returns an underscore-separated short name for the given locale. This will usually closely resemble the value returned by the IetfName property.


[read-only] scriptCode : string

Returns the four-character code denoting the script used for this language. For example, English would return 'Latn' (Latin), while Japanese would return 'Japn'.


[read-only] scriptName : string

Returns the name of the script used for this language.


Signal Documentation

localeChanged()

Signal emitted when the locale being used by the app has changed.

Note: The corresponding handler is onLocaleChanged.


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close