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":
|
2022-02-04 15:45:06 -05:00
|
|
|
return "简体中文";
|
|
|
|
|
|
|
|
// Then in alphabetical order
|
|
|
|
case "de":
|
|
|
|
return "Deutsch";
|
|
|
|
case "es":
|
|
|
|
return "Español";
|
2022-02-01 09:12:59 +08:00
|
|
|
case "fr":
|
2022-02-25 02:48:47 +01:00
|
|
|
switch (locale.countryCode) {
|
|
|
|
case "CA" :
|
|
|
|
return "Français (CA)";
|
|
|
|
case "FR" :
|
|
|
|
return "Français (FR)";
|
|
|
|
default :
|
|
|
|
return locale.languageCode;
|
|
|
|
}
|
2022-02-04 15:45:06 -05:00
|
|
|
case "it":
|
|
|
|
return "Italiano";
|
|
|
|
case "ru":
|
|
|
|
return "русский";
|
|
|
|
|
|
|
|
// If not found then the language code will be displayed
|
2022-02-01 09:12:59 +08:00
|
|
|
default:
|
2022-02-04 15:45:06 -05:00
|
|
|
return locale.languageCode;
|
2022-02-01 09:12:59 +08:00
|
|
|
}
|
|
|
|
}
|