Get item name in a specific language

Discussion in 'Plugin Development' started by Maxx_Qc, Dec 31, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Maxx_Qc

    Hello, I want to get the name of an item in a specific language.
    Is there any way to do it?
    I did a lot of search on the forums but did not find anything.
    Thank you!
     
  2. Offline

    elian1203

  3. Offline

    Maxx_Qc

  4. Offline

    elian1203

    Oh really? How do you use it @Maxx_Qc?
     
  5. Offline

    Xerox262

    What did you try searching on google? There's a way to do it through tellraw, but I doubt you want to send the player it in chat, what are you trying to do?

    @elian1203 /tellraw @a {translate:"item.ghastTear.name"} Will show player the words "Ghast tear" in whatever language that they have chosen.
     
  6. Offline

    Maxx_Qc

    Go check in the assets for the lang file

    I don't want to send it so the player will see it in his own language, I want to send it in a specific language (ex: French) whatever the player's language is
     
  7. Offline

    Xerox262

    That's what I said, you want to send the player the message in the language they selected.

    Minecraft's language system only translates what is in that lang file, you can't use it to say Translate chat messages to languages for people to understand, you still haven't told us what exactly you're trying to do with it.
     
  8. Offline

    Maxx_Qc

    Can you read? I said that I want to send a item's name in a specific language (in my case fr_FR) to players and not in their selected language.
     
  9. Offline

    Xerox262

    @Maxx_Qc Re-read what you said
    The problem is that the lang files are client side and not server side, if you want to use them you will have to include them in your plugin, after that you would be able to use the french file as you see fit.
     
  10. Offline

    Maxx_Qc

    No problem with that, I just want to send the name of a Iron Sword in french to a player (for example).
    I can include the lang file but I don't know how to get the name of the iron sword in the file.
     
  11. Offline

    Xerox262

    In what way do you not know how to get the name? Like you don't know what to search for in the file to find iron sword "item.swordIron.name" or you don't know how to search in the file itself?

    If the latter then you could make a custom configuration file, that scans through, line by line when you're creating it then add them to a HashMap with the key being something like "item.swordIron.name" and the value actually being the translated name.
    Or if you want to go the lazy way you could open the file in a text editor, then replace all "=" with ": " then load it as a yaml file.
     
    Maxx_Qc likes this.
  12. Offline

    Maxx_Qc

    @Xerox262 Thank you, I to get the localized name of an item do I need to do getItemMeta().getDisplayName()?
     
  13. Offline

    Xerox262

    @Maxx_Qc ItemMeta#getDisplayName only returns custom name, if there's no name set it will return null.
     
  14. Offline

    Maxx_Qc

    @Xerox262 so how can I do it?
    With type?
     
  15. Offline

    mythbusterma

    @Maxx_Qc

    You can save the item name in the config as the Material's toString() value, and then look it up in a config file that corresponds to a language.

    There's no need to have an attitude with people trying to help you.
     
Thread Status:
Not open for further replies.

Share This Page