import 'package:get/get.dart';

import '../../features/home/business_logic_layer/home_controller.dart';
import '../local_storage/local_storage.dart';

class LanguageInit {
  static LocalStorage storage = LocalStorage();
  static String? language;
  static String deviceLanguage = 'en';

  static void langugeInite() {
    deviceLanguage = Get.deviceLocale!.languageCode;
    if (deviceLanguage.substring(0, 2) == 'ar') {
      deviceLanguage = 'ar';
    } else {
      deviceLanguage = 'en';
    }
    language = storage.getLanguage() ?? deviceLanguage;
    HomeController homeController = Get.find<HomeController>();
    homeController
        .setUiLanguage(LanguageInit.language ?? LanguageInit.deviceLanguage);
  }
}
