translate static method

String translate(
  1. String key
)

Implementation

static String translate(String key) {
  final deviceLocale = Get.deviceLocale;
  final languageCode = deviceLocale?.languageCode;

  switch (languageCode) {
    case 'zh':
    case 'en':
      Get.locale ??= deviceLocale;
      break;
    default:
      Get.locale = const Locale(fallbackLocale);
  }

  final language = Get.locale?.languageCode ?? fallbackLocale;
  return translations[language]?[key] ?? key;
}