lloydtorres / stately

A NationStates app for Android.
https://play.google.com/store/apps/details?id=com.lloydtorres.stately
Apache License 2.0
30 stars 8 forks source link

Format multi-word currency unit as on website #10

Closed jh0ker closed 8 years ago

jh0ker commented 8 years ago

Title explains it all - I have noticed that on the website, if you have a currency unit like bar of gold, the plural will be bars of gold. In the app, it will show as bar of golds. This change is untested as I have no android build suite set up (I am no Android dev). I am sorry about that.

Edit: Love your app, by the way!

lloydtorres commented 8 years ago

Thanks for contributing! And thank you for pointing out this issue as well.

The implementation here assumes that the first word in the currency unit will always be pluralized. This works for bar of gold, but it doesn't work for something like golden bar (which returns goldens bar).

I recommend using a regex pattern like (?i)(.+) of .+ instead to check if the currency unit follows the pattern x of y (which NS seems to pluralize for every case), then pluralizing everything inside the capturing group.

Do you know if NS has other special pluralization cases besides this?

jh0ker commented 8 years ago

That sounds like a solid approach. A good regex seems to be ^(.+?)( +of .+)?$ (https://repl.it/CJ7s/1) I have not noticed any other special pluralization rules yet.

jh0ker commented 8 years ago

I think this regex should cover all eventualities :smile:

lloydtorres commented 8 years ago

Looks good, thank you so much for your help! I'll merge it to master and push it on the next update. :)

If you don't mind, can I add your name (or username if you prefer) to a list of contributors within the app?

jh0ker commented 8 years ago

I would be honored :)