wjc
2025-04-11 1a08f52ec36e3b71204a23a8813fe50f1748b277
app/src/main/java/com/hdl/photovoltaic/HDLApp.java
@@ -99,8 +99,8 @@
        String language = UserConfigManage.getInstance().getCurrentAppLanguage();
        if (TextUtils.isEmpty(language)) {
            //从内存里面获取不到语言,获取当前系统的;
            String str = getResources().getConfiguration().locale.getCountry();
            if (str.equals("CN") || str.equals("TW")) {
            String str = getResources().getConfiguration().locale.getLanguage();
            if (str.equals(LocalManageUtil.zh)) {
                UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.zh);
            } else {
                UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.en);
@@ -349,6 +349,7 @@
        });
    }
    /**
     * 初始化uni app mqtt
     */
@@ -366,6 +367,7 @@
        }
    }
    @Override
    protected void attachBaseContext(Context base) {
        MultiDex.install(base);
@@ -375,6 +377,23 @@
    /**
     * 支持中英文切换
     */
    public Context getAppLocaleContext(Context context) {
        try {
            Locale locale = new Locale(UserConfigManage.getInstance().getCurrentAppLanguage());
            Configuration configuration = context.getResources().getConfiguration();
            configuration.setLocale(locale);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                configuration.setLocales(new LocaleList(locale));
            }
            return context.createConfigurationContext(configuration);
        } catch (Exception e) {
            return context;
        }
    }
    /**
     * 支持中英文切换
     */
    public Context getAppLocaleContext() {
        try {
            Locale locale = new Locale(UserConfigManage.getInstance().getCurrentAppLanguage());