Jump to content

getDisplayName() always return english name?


DrEinsteinium

Recommended Posts

Hi guys, one of the users of my mod WikiLink just pointed out that using WikiLink with different languages such as Spanish while trying to automatically search a wiki for the item in your hand searches the wiki for the Spanish name of the item.

 

Does anyone know of a method where I can always get the english name of

 

player.getHeldItem().getDisplayName();

 

Edit -- Better yet, does anyone know how to get what language someone is using?

Follow me on twitter! @keepablock

Read up on whats new! www.catacombs.co

width=700 height=60http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]

Link to comment
Share on other sites

I know I have seen this somewhere....

 

There is some class I BELIEVE is called StatCollector (or something very similar) which turns the name of what you put in to the language that is selected...

 

(WTF? Why did I think it was stat collector????????)

 

Okay after a little bit of searching, I have found this class: StringTranslate. Within that class is a public variable called currentLanguage. This gives the current language (obviously). This would only work with the Vanilla items I believe because I do not know of a way to have modded items change name depending on language. But then again, thats just me.

 

So I guess you wouldn't really need the current language. You would just have to get the the registered name from LanguageRegistry. Thats what you really need. Because of that your job SHOULD be fairly easy. Anyway, I have to go now, you have really intrigued me with this question so I will be back to look later.

 

I hope I have pointed you in the right direction. Looking back though I have started to ramble... Sorry xD

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Let me better explain my problem.

 

Users of WikiLink that speak different language and that use different language settings in Minecraft are going to have problems when they go to search one of the wikis. The mod will pick up the display name of the item in their hand and the mod will end up searching the english version of the minecraft wiki for a spanish named item.

 

So here is what I was thinking: Instead of always returning the english version of an item, why not go ahead and find what language the user is set to and search the wiki for their language. After all, the official Minecraft Wiki does have a lot of translations. 

 

So it would be a giant if statement

public static void getLocalizedWiki()
{
    if (language == "en_US")
    {
        return "minecraftwiki.net";
    }
    else if (language == "sp_ES"
    {
        return "es.minecraftwiki.net";
    }
}

 

But the golden question is: How do I get the current language that the user is set to?

Follow me on twitter! @keepablock

Read up on whats new! www.catacombs.co

width=700 height=60http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]

Link to comment
Share on other sites

Didn't I already give that in my earlier answer? I will agree that GoToLink's answer is a bit better though....

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

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.

Announcements



×
×
  • Create New...

Important Information

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