Jump to content

Help with changing the client locale of Minecraft with mod code


Ensamisten

Recommended Posts

Hello, I got some code that won't register in Forge (MC=1.20.4), (FML=49.0.30) (It basically iterates through an array all supported Minecraft languages and picks at random one and reloads ResourceManager with it:

 

 

List<String> languageCountryCodes = new ArrayList<>();
        Collections.addAll(languageCountryCodes,
                "af_za", "ara_sa", "ast_es", "aze_az", "bak_ru", "bar_de", "bel_by", "bul_bg", "bre_fr", "qbr_nl",
                "bos_ba", "cat_es", "ces_cz", "cym_gb", "dan_dk", "bar_at", "gsw_ch", "deu_de", "ell_gr", "eng_au",
                "eng_ca", "eng_gb", "eng_nz", "qpe", "eng_qabs_gb", "en_ud", "epo", "spa_ar", "spa_cl", "spa_ec",
                "spa_es", "spa_mx", "spa_uy", "spa_ve", "spa_es_an", "est_ee", "eus_es", "fas_ir", "fin_fi", "fil_ph",
                "fao_fo", "fra_ca", "fra_fr", "fra_de", "fur_it", "fry_nl", "gle_ie", "gla_gb", "glg_es", "haw_us",
                "heb_il", "hin_in", "hrv_hr", "hun_hu", "hye_am", "id_id", "ibo_ng", "is_is", "qis", "ita_it", "jpn_jp",
                "jbo", "kat_ge", "kaz_kz", "kan_in", "kor_kr", "ksh_de", "kw_gb", "lat_va", "ltz_lu", "lim_nl", "lmo_it",
                "lao_la", "qll", "lit_lt", "lav_lv", "lzh", "mkd_mk", "mon_mn", "zlm_my", "mlt_mt", "nhe_mx", "vmf_de",
                "msa_my", "mlg_mg", "mar_in", "nld_be", "nld_nl", "nno_no", "nob_no", "quc_latn_gt", "pol_pl", "por_br",
                "por_pt", "qya", "ro_ro", "qpr", "rus_ru", "srp_latn_rs", "srp_cyrl_rs", "swe_se", "slk_sk", "slv_si",
                "som_so", "sqi_al", "ckb_ir", "sr_sp", "swa_ke", "swh_tz", "tam_in", "tha_th", "tgk_tj", "uig_cn",
                "ukr_ua", "urd_pk", "uzb_uz", "ven_za", "cymr", "xho_za", "yor_ng", "yue_hk", "zho_hans_cn", "zho_hant_hk",
                "zho_hant_tw");

        // Shuffle the list
        Collections.shuffle(languageCountryCodes);

        // Print one code at a time
        for (String code : languageCountryCodes) {
            LanguageManager languageManager = new LanguageManager(code);
            languageManager.onResourceManagerReload(TroubleshootingMod.getResourceManager());
            System.out.println(Minecraft.getInstance().getLocale());
            System.out.println(code);
            break; // Exit the loop after printing one code
        }

Minecraft.getInstance().getLanguageManager().setSelected("bar_de"); also does not appear to be functional..

 

Kind regards, Ensamisten

Edited by Ensamisten
Forgot code
Link to comment
Share on other sites

Your new LanguageManager() is not the language manager that is being used when you call Minecraft.getInstant().getLocale().

Minecraft.getLanguageManager().setSelected(code);  should work.  Can you show that code?

Edited by GoldenPanda
Link to comment
Share on other sites

17 hours ago, GoldenPanda said:

Your new LanguageManager() is not the language manager that is being used when you call Minecraft.getInstant().getLocale().

Minecraft.getLanguageManager().setSelected(code);  should work.  Can you show that code?

  1. It is yet to function, subscribing to the different Forge stages doesn't change it at all.
  2. Forge does not seem to provide an interface for this, only for internal code.
 // Print one code at a time
        for (String code : languageCountryCodes) {
            Minecraft.getInstance().getLanguageManager().setSelected(code);
            Minecraft.getInstance().getLocale();
            break; // Exit the loop after printing one code
        }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.