Docs

Locale

The locale service allow you customize your app based on your user location. Get your user location, IP address, list of countries names, phone codes, currencies and more. This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com.

Get User Locale

GET/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 supported language.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
    ;
    
    let promise = sdk.locale.getLocale();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->getLocale();
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new Locale.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        setProject('')
        setKey('')
    ;
    
    let promise = locale.getLocale();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

List Countries

GET/locale/countries

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

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
    ;
    
    let promise = sdk.locale.getCountries();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->getCountries();
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new Locale.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        setProject('')
        setKey('')
    ;
    
    let promise = locale.getCountries();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

List EU Countries

GET/locale/countries/eu

List of all countries that are currently members of the EU. You can use the locale header to get the data in supported language. UK brexit date is currently set to 2019-10-31 and will be updated if and when needed.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
    ;
    
    let promise = sdk.locale.getCountriesEU();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->getCountriesEU();
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new Locale.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        setProject('')
        setKey('')
    ;
    
    let promise = locale.getCountriesEU();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

List Countries Phone Codes

GET/locale/countries/phones

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

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
    ;
    
    let promise = sdk.locale.getCountriesPhones();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->getCountriesPhones();
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new Locale.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        setProject('')
        setKey('')
    ;
    
    let promise = locale.getCountriesPhones();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

List of currencies

GET/locale/currencies

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

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
    ;
    
    let promise = sdk.locale.getCurrencies();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->getCurrencies();
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new Locale.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        setProject('')
        setKey('')
    ;
    
    let promise = locale.getCurrencies();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });