Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

2.1 KB
Raw Blame
import 'package:flutter/material.dart';

String languageFromLocale(Locale locale) {
  switch (locale.languageCode) {
    // Most often used languages
    case "en":
      switch (locale.countryCode) {
        case "GB":
          return "English (GB)";
        case "US":
          return "English (US)";
        default:
          return "English (US)";
      }
    case "zh":
      switch (locale.countryCode) {
        case "CN":
          return "简体中文";
        case "TW":
          return "繁體中文";
        default:
          return locale.languageCode;
      }

    // Then in alphabetical order
    case "am":
      return "አማርኛ";
    case "ar":
      return "العربية";
    case "ca":
      return "Català";
    case "cs":
      return "Čeština";
    case "ckb":
      switch (locale.countryCode) {
        case "KU":
          return "کوردی سۆرانی";
        default:
          return locale.languageCode;
      }
    case "de":
      return "Deutsch";
    case "es":
      return "Español";
    case "eu":
      return "Euskera";
    case "el":
      return "Ελληνικά";
    case "fr":
      switch (locale.countryCode) {
        case "CA":
          return "Français (CA)";
        case "FR":
          return "Français (FR)";
        default:
          return locale.languageCode;
      }
    case "mr":
      return "मराठी";
    case "he":
      return "עברית";
    case "hu":
      return "Magyar";
    case "id":
      return "Bahasa Indonesia";
    case "it":
      return "Italiano";
    case "ja":
      return "日本語";
    case "ko":
      return "한국어";
    case "pl":
      return "Polski";
    case "pt":
      return "Português";
    case "ru":
      return "русский";
    case "sv":
      return "Svenska";
    case "th":
      return "ไทย";
    case "tr":
      return "Türkçe";
    case "fa":
      return "فارسی";
    case "uk":
      return "українська";
    case "ur":
      return "اردو";
    case "hin":
      return "हिन्दी";
  }
  // If not found then the language code will be displayed
  return locale.languageCode;
}