Locale

SERVER

The Locale service allows you to customize your app based on your users' location. Using this service, you can get your users' location, IP address, list of countries and continents names, phone codes, currencies, and more. Country codes returned follow the ISO 3166-1 standard.

The user service supports multiple locales. This feature allows you to fetch countries and continents information in your app language. To switch locales, all you need to do is pass the 'X-Appwrite-Locale' header or set the 'setLocale' method using any of our available SDKs. View here the list of available locales.

Base URL
https://cloud.appwrite.io/v1

Get User Locale

Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language.

(IP Geolocation by DB-IP)

  • Response
Endpoint
GET /locale
Java
import io.appwrite.Client
import io.appwrite.services.Locale

public void main() {
    Client client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
        .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key

    Locale locale = new Locale(client);
    locale.get(new Continuation<Response>() {
        @NotNull
        @Override
        public CoroutineContext getContext() {
            return EmptyCoroutineContext.INSTANCE;
        }

        @Override
        public void resumeWith(@NotNull Object o) {
            String json = "";
            try {
                if (o instanceof Result.Failure) {
                    Result.Failure failure = (Result.Failure) o;
                    throw failure.exception;
                } else {
                    Response response = (Response) o;
                }
            } catch (Throwable th) {
                Log.e("ERROR", th.toString());
            }
        }
    });
}

List Continents

List of all continents. You can use the locale header to get the data in a supported language.

Endpoint
GET /locale/continents
Java
import io.appwrite.Client
import io.appwrite.services.Locale

public void main() {
    Client client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
        .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key

    Locale locale = new Locale(client);
    locale.getContinents(new Continuation<Response>() {
        @NotNull
        @Override
        public CoroutineContext getContext() {
            return EmptyCoroutineContext.INSTANCE;
        }

        @Override
        public void resumeWith(@NotNull Object o) {
            String json = "";
            try {
                if (o instanceof Result.Failure) {
                    Result.Failure failure = (Result.Failure) o;
                    throw failure.exception;
                } else {
                    Response response = (Response) o;
                }
            } catch (Throwable th) {
                Log.e("ERROR", th.toString());
            }
        }
    });
}

List Countries

List of all countries. You can use the locale header to get the data in a supported language.

Endpoint
GET /locale/countries
Java
import io.appwrite.Client
import io.appwrite.services.Locale

public void main() {
    Client client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
        .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key

    Locale locale = new Locale(client);
    locale.getCountries(new Continuation<Response>() {
        @NotNull
        @Override
        public CoroutineContext getContext() {
            return EmptyCoroutineContext.INSTANCE;
        }

        @Override
        public void resumeWith(@NotNull Object o) {
            String json = "";
            try {
                if (o instanceof Result.Failure) {
                    Result.Failure failure = (Result.Failure) o;
                    throw failure.exception;
                } else {
                    Response response = (Response) o;
                }
            } catch (Throwable th) {
                Log.e("ERROR", th.toString());
            }
        }
    });
}

List EU Countries

List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language.

Endpoint
GET /locale/countries/eu
Java
import io.appwrite.Client
import io.appwrite.services.Locale

public void main() {
    Client client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
        .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key

    Locale locale = new Locale(client);
    locale.getCountriesEU(new Continuation<Response>() {
        @NotNull
        @Override
        public CoroutineContext getContext() {
            return EmptyCoroutineContext.INSTANCE;
        }

        @Override
        public void resumeWith(@NotNull Object o) {
            String json = "";
            try {
                if (o instanceof Result.Failure) {
                    Result.Failure failure = (Result.Failure) o;
                    throw failure.exception;
                } else {
                    Response response = (Response) o;
                }
            } catch (Throwable th) {
                Log.e("ERROR", th.toString());
            }
        }
    });
}

List Countries Phone Codes

List of all countries phone codes. You can use the locale header to get the data in a supported language.

Endpoint
GET /locale/countries/phones
Java
import io.appwrite.Client
import io.appwrite.services.Locale

public void main() {
    Client client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
        .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key

    Locale locale = new Locale(client);
    locale.getCountriesPhones(new Continuation<Response>() {
        @NotNull
        @Override
        public CoroutineContext getContext() {
            return EmptyCoroutineContext.INSTANCE;
        }

        @Override
        public void resumeWith(@NotNull Object o) {
            String json = "";
            try {
                if (o instanceof Result.Failure) {
                    Result.Failure failure = (Result.Failure) o;
                    throw failure.exception;
                } else {
                    Response response = (Response) o;
                }
            } catch (Throwable th) {
                Log.e("ERROR", th.toString());
            }
        }
    });
}

List Currencies

List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language.

Endpoint
GET /locale/currencies
Java
import io.appwrite.Client
import io.appwrite.services.Locale

public void main() {
    Client client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
        .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key

    Locale locale = new Locale(client);
    locale.getCurrencies(new Continuation<Response>() {
        @NotNull
        @Override
        public CoroutineContext getContext() {
            return EmptyCoroutineContext.INSTANCE;
        }

        @Override
        public void resumeWith(@NotNull Object o) {
            String json = "";
            try {
                if (o instanceof Result.Failure) {
                    Result.Failure failure = (Result.Failure) o;
                    throw failure.exception;
                } else {
                    Response response = (Response) o;
                }
            } catch (Throwable th) {
                Log.e("ERROR", th.toString());
            }
        }
    });
}

List Languages

List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.

Endpoint
GET /locale/languages
Java
import io.appwrite.Client
import io.appwrite.services.Locale

public void main() {
    Client client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
        .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key

    Locale locale = new Locale(client);
    locale.getLanguages(new Continuation<Response>() {
        @NotNull
        @Override
        public CoroutineContext getContext() {
            return EmptyCoroutineContext.INSTANCE;
        }

        @Override
        public void resumeWith(@NotNull Object o) {
            String json = "";
            try {
                if (o instanceof Result.Failure) {
                    Result.Failure failure = (Result.Failure) o;
                    throw failure.exception;
                } else {
                    Response response = (Response) o;
                }
            } catch (Throwable th) {
                Log.e("ERROR", th.toString());
            }
        }
    });
}