Locale

CLIENT

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
Apple
import Appwrite

func main() async throws {
    let client = Client()
      .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
      .setProject("5df5acd0d48c2") // Your project ID
    let locale = Locale(client)
    let locale = try await locale.get()

    print(String(describing: locale)
}

List Continents

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

Endpoint
GET /locale/continents
Apple
import Appwrite

func main() async throws {
    let client = Client()
      .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
      .setProject("5df5acd0d48c2") // Your project ID
    let locale = Locale(client)
    let continentList = try await locale.getContinents()

    print(String(describing: continentList)
}

List Countries

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

Endpoint
GET /locale/countries
Apple
import Appwrite

func main() async throws {
    let client = Client()
      .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
      .setProject("5df5acd0d48c2") // Your project ID
    let locale = Locale(client)
    let countryList = try await locale.getCountries()

    print(String(describing: countryList)
}

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
Apple
import Appwrite

func main() async throws {
    let client = Client()
      .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
      .setProject("5df5acd0d48c2") // Your project ID
    let locale = Locale(client)
    let countryList = try await locale.getCountriesEU()

    print(String(describing: countryList)
}

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
Apple
import Appwrite

func main() async throws {
    let client = Client()
      .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
      .setProject("5df5acd0d48c2") // Your project ID
    let locale = Locale(client)
    let phoneList = try await locale.getCountriesPhones()

    print(String(describing: phoneList)
}

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
Apple
import Appwrite

func main() async throws {
    let client = Client()
      .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
      .setProject("5df5acd0d48c2") // Your project ID
    let locale = Locale(client)
    let currencyList = try await locale.getCurrencies()

    print(String(describing: currencyList)
}

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
Apple
import Appwrite

func main() async throws {
    let client = Client()
      .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
      .setProject("5df5acd0d48c2") // Your project ID
    let locale = Locale(client)
    let languageList = try await locale.getLanguages()

    print(String(describing: languageList)
}