hulkrelax / hltb-for-deck

A plugin to show you game lengths according to How Long To Beat
MIT License
51 stars 16 forks source link

Add non-english game title support #20

Open alecchen opened 1 year ago

alecchen commented 1 year ago

First at all, I don't have any experience in web development/typescript/React. I did my best searching on Stackoverflow and google then modifying the source code based on the original hltb-for-deck, so please feel free to reject or modify my changes.

I found the non-english game title will become a empty string after applying normalize function, and it leads the result always points to "https://howlongtobeat.com/game/95647". So instead I using steam api "http://store.steampowered.com/api/appdetails?appids={APP_ID}" to get json information and parsing the english game title, and then pass it to useHtlb.

Tested languages: Traditional Chinese, Korean, Japanese, Spanish and Russian. All of them work as expected. Tested steam item: 'Hogwarts Legacy' 990080 , 'Paradise Killer' 1160220, 'Detention' 555220, 'Black Desert' 1258320

During the testing, found steam id 1258320 didn't get correct hltb record, which was due to the item is no longer available on steam and there's a '(retire)' after the game title. Modify the normalize function in src/utils.ts to remove '(retire)' string.

Hogwarts Legacy hltb-for-deck-1

Paradise Killer hltb-for-deck-2

hulkrelax commented 1 year ago

I don't think this will work for non-Steam games.

hulkrelax commented 1 year ago

I don't think this will work for non-Steam games.

I can maybe try to incorporate this code to try this explicitly for steam games. I appreciate the contribution. I will credit you if/when I make the change

TROLLERLOLL commented 4 months ago

@alecchen Hi As far as I'm aware this is the current active repo https://github.com/SDH-Stewardship/hltb-for-deck