Jump to content

Recommended Posts

Posted

My mod uses a language file en_US.lang which has worked perfectly in 1.7.2. Today I tried upgrading to Forge-1.7.10-10.13.0.1152 and now it throws a null pointer exception whenever I try to access a key from my language file. Debugging the error shows that the languageMap variable in LanguageManager.java is empty, so it returns null when attempting to get the key "en_US".

 

Is there another function I need to run to get the language files to setup properly before using them, or is this an error on Forge's part (it is a beta version after all)?

 

My code to get the localized string value:

    public static String get(String key)
    {
        String text = LanguageRegistry.instance().getStringLocalization(key);

        if (text == null || text.equals(""))
            text = LanguageRegistry.instance().getStringLocalization(key, "en_US");

        return text;
    }

 

crashlog:

 

  Reveal hidden contents

[/code]

Posted

Solved the issue. Need to use the same function that Minecraft uses for their translations:

 

    public static String get(String key)
    {
    	return I18n.format(key, new Object[0]);
    }

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.

Announcements



×
×
  • Create New...

Important Information

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