Dimillian / ACHNBrowserUI

Animal Crossing New Horizon companion app in SwiftUI
https://apps.apple.com/us/app/ac-helper/id1508764244?ls=1
Apache License 2.0
1.69k stars 185 forks source link

Item / data localization #44

Open bigrck64 opened 4 years ago

bigrck64 commented 4 years ago

As you know, the http://acnhapi.com/ can display any catalog item in the correct localisation. Would it be possible to add on option to let user choose the database language ?

Dimillian commented 4 years ago

For items we use a local catalog dump, which for now is english only. In the mid/long I think we'll need to localize it fully. For villagers I'll display their name in your local language if available quite soon as we have the info from acnhapi yeah :) And for the rest of the app, the UI, anyone is welcome to do a PR do make it available :)

ericlewis commented 4 years ago

should be relatively easy to generate a localization from this: https://pastebin.com/B8N5KKsh. has strings for diff languages in relation to items.

vknabel commented 4 years ago

What are the preferred plans for this? Do you prefer translation relying on Localizable.strings or by patching the JSON-files?

Dimillian commented 4 years ago

I’ll take a look at that a bit later, but with 5000+ items we’ll use a translated data source, I’ll just pull another json.

vknabel commented 4 years ago

Maybe imthe666st/ACNH can help you here. I also wrote a short playground script to generate a Localizable.strings file.

Only tested it for a few minutes, but works pretty well after adding a few LocalizedStringKey and NSLocalizedString.

Dimillian commented 4 years ago

This is perfect! Thank you so much for the repo link. With those JSON we just have to match the internal id with our datasource and done. Crazy. I'll be able to do it in no time :)

Dimillian commented 4 years ago

Note: We'll not use Localizable.string. I'll pull the Locale from the phone, and then load the appropriate translation JSON and replace the item name with the one pulled from the file.

Dimillian commented 4 years ago

You're code is a great help, I'm almost done :)

Dimillian commented 4 years ago
Screenshot 2020-05-11 at 08 55 43
vknabel commented 4 years ago

Great to hear and happy to help! The localizable approach was just the quickest and easiest way to get a prototype working. I guess patching the dataset is better, too!

As a side note: in the current data set, the first letter is capitalized, whereas in the linked one most names are lowercased in English.

Dimillian commented 4 years ago

Yup fixed that too, commiting in 5 minutes. You'll see, I like the approach I did. We load current localization table in memory in just query it from the Item.

Dimillian commented 4 years ago

https://github.com/Dimillian/ACHNBrowserUI/commit/081c8469d9f8b4c04ae336a49565967ce9f6ec01 @vknabel It's basic but it works :) So happy we have that nailed down in so little time!

Dimillian commented 4 years ago

You're welcome to do adjustment as you see fit :)

vknabel commented 4 years ago

Thank you very much @Dimillian. I will take a look this evening in about 9-12 hours!

bigrck64 commented 4 years ago

Awesome that was quick ! :)

vknabel commented 4 years ago

It works very well! From my perspective, this is done. I opened #111 for a small and rare edge case. But good and blazingly fast work!

Dimillian commented 4 years ago

For items localizations data for now we have:

Arnoud-B commented 3 years ago

Would it be possible to add on option to let user choose the database language ?

That would be great indeed. I have my phone set to English but the game is set to French. Makes it quite hard to find items 😉

TheVaan commented 3 years ago

Hey @Arnoud-B, you already can do that. You can set App language to a different then device language. Go to iOS settings app, scroll down to app section, select AC Helper and set language to French. (Screenshots are German, but I think you'll get what to do) image image

Arnoud-B commented 3 years ago

Thanks @TheVaan. That solves it indeed, but I think most users won't go to the Settings app to find this option but instead rely on the app settings (in the app itself). Why not expose it there?

TheVaan commented 3 years ago

We did this because of apples localization guide lines. There are ways to build in a translation Switcher inside an app but this is often buggy (for SwiftUi). We decided to use the Apple way (introduced in iOS 13) and not to implement a buggy way. I agree it's not that easy to find but it's the way Apple wants us to do.

Arnoud-B commented 3 years ago

OK, good to know. Perhaps a mention in the app with a direct link to the AC Helper section in the Settings would be worth considering? (I've seen that in several apps)