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
Go
package main

import (
    "fmt"
    "github.com/appwrite/sdk-for-go/client"
    "github.com/appwrite/sdk-for-go/locale"
)

func main() {
    client := client.NewClient()

    client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
    client.SetSession("") // The user session to authenticate with

    service := locale.NewLocale(client)
    response, error := service.Get(
    )

    if error != nil {
        panic(error)
    }

    fmt.Println(response)
}

List locale codes

List of all locale codes in ISO 639-1.

Endpoint
GET /locale/codes
Go
package main

import (
    "fmt"
    "github.com/appwrite/sdk-for-go/client"
    "github.com/appwrite/sdk-for-go/locale"
)

func main() {
    client := client.NewClient()

    client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
    client.SetSession("") // The user session to authenticate with

    service := locale.NewLocale(client)
    response, error := service.ListCodes(
    )

    if error != nil {
        panic(error)
    }

    fmt.Println(response)
}

List continents

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

Endpoint
GET /locale/continents
Go
package main

import (
    "fmt"
    "github.com/appwrite/sdk-for-go/client"
    "github.com/appwrite/sdk-for-go/locale"
)

func main() {
    client := client.NewClient()

    client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
    client.SetSession("") // The user session to authenticate with

    service := locale.NewLocale(client)
    response, error := service.ListContinents(
    )

    if error != nil {
        panic(error)
    }

    fmt.Println(response)
}

List countries

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

Endpoint
GET /locale/countries
Go
package main

import (
    "fmt"
    "github.com/appwrite/sdk-for-go/client"
    "github.com/appwrite/sdk-for-go/locale"
)

func main() {
    client := client.NewClient()

    client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
    client.SetSession("") // The user session to authenticate with

    service := locale.NewLocale(client)
    response, error := service.ListCountries(
    )

    if error != nil {
        panic(error)
    }

    fmt.Println(response)
}

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
Go
package main

import (
    "fmt"
    "github.com/appwrite/sdk-for-go/client"
    "github.com/appwrite/sdk-for-go/locale"
)

func main() {
    client := client.NewClient()

    client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
    client.SetSession("") // The user session to authenticate with

    service := locale.NewLocale(client)
    response, error := service.ListCountriesEU(
    )

    if error != nil {
        panic(error)
    }

    fmt.Println(response)
}

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
Go
package main

import (
    "fmt"
    "github.com/appwrite/sdk-for-go/client"
    "github.com/appwrite/sdk-for-go/locale"
)

func main() {
    client := client.NewClient()

    client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
    client.SetSession("") // The user session to authenticate with

    service := locale.NewLocale(client)
    response, error := service.ListCountriesPhones(
    )

    if error != nil {
        panic(error)
    }

    fmt.Println(response)
}

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
Go
package main

import (
    "fmt"
    "github.com/appwrite/sdk-for-go/client"
    "github.com/appwrite/sdk-for-go/locale"
)

func main() {
    client := client.NewClient()

    client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
    client.SetSession("") // The user session to authenticate with

    service := locale.NewLocale(client)
    response, error := service.ListCurrencies(
    )

    if error != nil {
        panic(error)
    }

    fmt.Println(response)
}

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
Go
package main

import (
    "fmt"
    "github.com/appwrite/sdk-for-go/client"
    "github.com/appwrite/sdk-for-go/locale"
)

func main() {
    client := client.NewClient()

    client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
    client.SetSession("") // The user session to authenticate with

    service := locale.NewLocale(client)
    response, error := service.ListLanguages(
    )

    if error != nil {
        panic(error)
    }

    fmt.Println(response)
}