Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

Add support for localized description - i.e. use language associated with currency. #24

Closed
mrdavey opened this issue Nov 22, 2015 · 10 comments

Comments

@mrdavey
Copy link

mrdavey commented Nov 22, 2015

In some countries, such as France/Germany/Italy/Spain, the Euro sign is placed after the amount. E.g. 3,50 € (note that they also use a ',' instead of '.' for sub units). More information can be found here: https://en.wikipedia.org/wiki/Euro_sign#Use

@danthorpe
Copy link
Owner

Hi @mrdavey thanks for the feedback. Have you seen a bug where the placement is incorrect?

@mrdavey
Copy link
Author

mrdavey commented Nov 22, 2015

Yes, when I use let amount = EUR(floatLiteral: money) as per our recent Twitter conversation.

It shows € 300.80 when it should be 300,80 € (if you were to follow the Euro standards currently in use).

@danthorpe
Copy link
Owner

Hmm. In Settings, what is your language set to?

@mrdavey
Copy link
Author

mrdavey commented Nov 22, 2015

Sorry for not explaining the use case properly. The app I'm creating shows multiple currencies (USD, EUR, CNY, etc) and the user can switch between the different currencies by selecting a button.

So at the moment, the simulator is set to US English. However I want users to be able to see the correct currency format and placement, no matter what language their device is set to.

It's more of a nitpick than a serious issue. :)

@danthorpe
Copy link
Owner

Yeah, I've considered this use case. At the moment, the implementation of CustomStringRepresentable uses standard NSNumberFormatter and NSLocale, so you get the representation of the currency in the current system language - which I think is the correct for most use cases.

To be able to display the language localized representation, without changing the language in settings is possible (I think) with NSLocale. Not immediately obvious what would be the best way to expose it on the type. Maybe as a money.localizedDescription? What do you think?

Regardless, I will update the README to make it clear at the top that those are in English language locale.

@mrdavey
Copy link
Author

mrdavey commented Nov 22, 2015

Yes money.localizedDescription could work well in this case. Thanks for taking the feedback on board @danthorpe . Much appreciated!

@danthorpe
Copy link
Owner

No props - will look into it today - look out for version 1.4.0.

@danthorpe danthorpe changed the title Placement of currency sign should have different options Add support for localized description - i.e. use language associated with currency. Nov 22, 2015
@danthorpe
Copy link
Owner

Clearly, the tricky thing with this, is say for example EUR which is used in many countries with different languages - it might require more information to say print out the Spanish localized description, versus the French localized description...

@danthorpe
Copy link
Owner

See #26 for work on this.

@danthorpe
Copy link
Owner

Hi @mrdavey - I've merged #26 into development, if you have time, please take a look, I think your use case should now be covered. The README has been updated to include the changes.

You can use the development branch in CocoaPods by doing:

pod 'Money', :git => 'https://github.com/danthorpe/Money', :branch => 'development'

or for Carthage:

github 'danthorpe/Money' 'development'

Please get back to me here if you have any issues - I really want to make sure that the formatting is bulletproof!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants