Version 0.6.1  
Docs

Locale API

Client integration with     code examples.


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.

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.

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 a supported language.

(IP Geolocation by DB-IP)

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.get();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    // Init SDK
    Client client = Client();
    Locale locale = Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    Future result = locale.get();
    
    result
      .then((response) {
        print(response);
      }).catchError((error) {
        print(error);
      });

List Countries

GET/locale/countries

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

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.getCountries();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    // Init SDK
    Client client = Client();
    Locale locale = Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    Future result = locale.getCountries();
    
    result
      .then((response) {
        print(response);
      }).catchError((error) {
        print(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 a supported language.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.getCountriesEU();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    // Init SDK
    Client client = Client();
    Locale locale = Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    Future result = locale.getCountriesEU();
    
    result
      .then((response) {
        print(response);
      }).catchError((error) {
        print(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 a supported language.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.getCountriesPhones();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    // Init SDK
    Client client = Client();
    Locale locale = Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    Future result = locale.getCountriesPhones();
    
    result
      .then((response) {
        print(response);
      }).catchError((error) {
        print(error);
      });

List Continents

GET/locale/continents

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

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.getContinents();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    // Init SDK
    Client client = Client();
    Locale locale = Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    Future result = locale.getContinents();
    
    result
      .then((response) {
        print(response);
      }).catchError((error) {
        print(error);
      });

List 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 a supported language.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.getCurrencies();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    // Init SDK
    Client client = Client();
    Locale locale = Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    Future result = locale.getCurrencies();
    
    result
      .then((response) {
        print(response);
      }).catchError((error) {
        print(error);
      });