2022-01-28 21:03:03 +05:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2022-02-04 15:45:06 -05:00
|
|
|
String languageFromLocale(Locale locale) {
|
2022-02-01 09:12:59 +08:00
|
|
|
switch (locale.languageCode) {
|
2022-02-04 15:45:06 -05:00
|
|
|
// Most often used languages
|
|
|
|
case "en":
|
|
|
|
return "English";
|
2022-02-01 09:12:59 +08:00
|
|
|
case "zh":
|
2023-04-03 12:53:54 +08:00
|
|
|
switch (locale.countryCode) {
|
|
|
|
case "CN":
|
|
|
|
return "简体中文";
|
|
|
|
case "TW":
|
|
|
|
return "繁體中文";
|
|
|
|
default:
|
|
|
|
return locale.languageCode;
|
|
|
|
}
|
2022-02-04 15:45:06 -05:00
|
|
|
|
|
|
|
// Then in alphabetical order
|
2023-10-24 17:41:46 +08:00
|
|
|
case "am":
|
|
|
|
return "አማርኛ";
|
2023-04-27 07:41:26 +02:00
|
|
|
case "ar":
|
|
|
|
return "العربية";
|
2022-02-27 16:08:11 +01:00
|
|
|
case "ca":
|
|
|
|
return "Català";
|
2024-03-09 05:25:04 +01:00
|
|
|
case "cs":
|
|
|
|
return "Čeština";
|
2024-02-19 13:13:01 +03:30
|
|
|
case "ckb":
|
|
|
|
switch (locale.countryCode) {
|
|
|
|
case "KU":
|
2024-04-24 09:18:06 +03:30
|
|
|
return "کوردی سۆرانی";
|
2024-02-19 20:48:06 +07:00
|
|
|
default:
|
|
|
|
return locale.languageCode;
|
2024-02-19 13:13:01 +03:30
|
|
|
}
|
2022-02-04 15:45:06 -05:00
|
|
|
case "de":
|
|
|
|
return "Deutsch";
|
|
|
|
case "es":
|
|
|
|
return "Español";
|
2023-01-18 10:20:42 +01:00
|
|
|
case "eu":
|
|
|
|
return "Euskera";
|
2024-03-16 10:53:34 +07:00
|
|
|
case "el":
|
|
|
|
return "Ελληνικά";
|
2022-02-01 09:12:59 +08:00
|
|
|
case "fr":
|
2022-02-28 11:46:01 +01:00
|
|
|
switch (locale.countryCode) {
|
|
|
|
case "CA":
|
2022-02-25 02:48:47 +01:00
|
|
|
return "Français (CA)";
|
2022-02-28 11:46:01 +01:00
|
|
|
case "FR":
|
2022-02-25 02:48:47 +01:00
|
|
|
return "Français (FR)";
|
2022-02-28 11:46:01 +01:00
|
|
|
default:
|
2022-02-25 02:48:47 +01:00
|
|
|
return locale.languageCode;
|
|
|
|
}
|
2022-02-28 11:46:01 +01:00
|
|
|
case "hu":
|
|
|
|
return "Magyar";
|
2022-07-25 13:33:50 +07:00
|
|
|
case "id":
|
2023-05-21 15:08:50 +08:00
|
|
|
return "Bahasa Indonesia";
|
2022-02-04 15:45:06 -05:00
|
|
|
case "it":
|
|
|
|
return "Italiano";
|
2022-05-06 00:40:20 +09:00
|
|
|
case "ja":
|
|
|
|
return "日本語";
|
2022-10-11 10:27:20 +09:00
|
|
|
case "ko":
|
|
|
|
return "한국어";
|
2022-03-15 21:08:31 +00:00
|
|
|
case "pl":
|
|
|
|
return "Polski";
|
2022-02-03 11:10:20 -03:00
|
|
|
case "pt":
|
|
|
|
return "Português";
|
2022-02-04 15:45:06 -05:00
|
|
|
case "ru":
|
|
|
|
return "русский";
|
2022-10-23 07:14:08 +02:00
|
|
|
case "sv":
|
|
|
|
return "Svenska";
|
2023-11-23 11:40:09 +07:00
|
|
|
case "th":
|
|
|
|
return "ไทย";
|
2022-02-28 16:00:53 +03:00
|
|
|
case "tr":
|
|
|
|
return "Türkçe";
|
2023-08-22 11:18:42 +03:30
|
|
|
case "fa":
|
|
|
|
return "فارسی";
|
2023-10-09 09:19:35 +05:00
|
|
|
case "uk":
|
|
|
|
return "українська";
|
2023-09-20 21:01:17 +05:30
|
|
|
case "ur":
|
|
|
|
return "اردو";
|
2023-10-15 19:43:14 +05:30
|
|
|
case "hin":
|
|
|
|
return "हिन्दी";
|
2022-02-01 09:12:59 +08:00
|
|
|
}
|
2024-02-20 08:22:06 +05:30
|
|
|
// If not found then the language code will be displayed
|
|
|
|
return locale.languageCode;
|
2022-02-01 09:12:59 +08:00
|
|
|
}
|