ISO Currency Code Support in KDE SC 4.4

I have previously posted that:

As part of my current localisation obsession, I've decided to pickup on an old wish list item to add support for the ISO 4217 Currency Code standard to KLocale.  Currently applications such as KSpread, KMyMoney, Skrooge, Kraft, KEuroCalc, and several Plasma currency converter widgets all have to maintain their own lists of codes and translations, which seems unnecessary duplication to me.

The good news is that after a few reviews and much help from the translation teams this feature made it in kdleibs for 4.4.  The easiest way to see what this involves is look at the System Settings Region module.  In the past, there was a simple lineedit that defaulted to a country's most common Currency Symbol and allowed the user to type in anything they liked.  It was simple and fine for merely formatting the occasional monetary amount for display, but pretty useless for apps working with multiple currencies or wanting to know a sane default: did $ mean USA or Canada or Australia or New Zealand or what?  Now KDE knows all the valid ISO Currency Codes, what the various valid symbols for them are, and even what countries the currencies are commonly used in, so the Region Money settings can now display combos to select the Currency by name and the Currency symbol:

Money settings

These new options make the Settings layout a bit long and crowded.  I had planned to simplify the Positive/Negative setting to a couple of combo boxes showing all the possible formats visually, but that will have to wait for 4.5.

The Currency combo gives you a list of all the available Currency Codes, with those used in the region prioritised at the top.  The example here is for Zimbabwe where the local Currency is currently suspended due to rampant inflation and the locals use anything trustworthy they can get their hands on:

Selecting a currency

Once you've selected your Currency, you can choose from the list of standard symbols for that Currency, here for the USD:

Select a Currency Symbol

This list is not translated, users are able to choose any commonly used symbol regardless of language or script, for example here is the symbol list for the Saudi Riyal:

Selecting other symbols

You will notice that the user no longer has the option to type in a symbol of their own choosing.  This is deliberate as I'm not sure we want the user to be able to type in a symbol that contradicts the chosen currency, i.e.choosing Japanese Yen but entering a Symbol of £.  The downside is that users who have personal preferences like extra punctuation or spacing are not able to have these anymore (well, not via the gui at any rate). I'll wait to see the user reaction.

Conversion to the new system is a little tricky.  If a user hasn't selected their own Currency Symbol and is using the region default, then everything is fine and they will just pick up the new default.  If they have selected their own symbol then we don't want to override that, but we also cannot tell what Currency Code they actually want (the ambiguous $ symbol problem again).  These users will continue to have their selected symbol used but with the (possibly contradictory) Currency Code of their region until such time as they go into the settings to correct things.

Another small addition is that KLocale now has separate settings for the number of decimal places for Money and Numbers instead of using the same setting for both.

Number settings options

If your code directly uses the old KLocale::fracDigits() method to obtain decimal places, please switch now to use either KLocale::decimalPlaces() or KLocale::monetaryDecimalPlaces() as appropriate.  I'll try chase them all down, but I'm not always sure which an app really wants. 

The benefit for coders from KCurrencyCode is mostly in having a common source of Currency Codes, symbols, and translated Currency names, which saves them creating and maintaining their own.  Have a look at the KCurrencyCode class in kdecore to see what's available and what you can use.  And don't forget that KLocale already provides a translation of all Country Names, there's no need to translate those a second time either.

A number of planned features didn't make it into this initial version, for example conversion and rounding rules.  I had hoped to have a 'fancy' money formatting routine to format $100.10 into "100 dollars and 10 cents" or even "one hundred dollars and ten cents" but there's a few translation issues that would need solving for that to be possible.

The 4.4 release comes with 204 Currency Codes, that is all currently valid Currencies in the ISO standard, and a number of major obsolete currencies for backwards compatibility.  For 4.5 there's another 85 or so obsolete currencies and other financial instruments that are defined in the standard that I could add, but that could just be an unnecessary burden on the translators so I'll make some judgment calls there.  If your app needs a particular Currency not yet available, then KCurrencyCode can be made to load your own config file.

Could I just ask for people in various countries to have a quick look at their own Currency and Country to make sure there's nothing wrong?  In particular, can you let me know if there are common variations for the symbols that are not yet supported?  The Currency config files are in kdebase/runtime/localization/currency and the Country config files in kdebase/runtime/l10n, or just run System Settings and have a play.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Scandinavian currencies

Nitpicking:The subunit of the scandinavian currencies have the following spellings:

SEK

CurrencySubunitSingular=öre36 CurrencySubunitPlural=öre

DKK/NOK

CurrencySubunitSingular=øre36 CurrencySubunitPlural=øre

[as opposed to:CurrencySubunitSingular=ore36 CurrencySubunitPlural=ore]

Even more nitpicky:SEK/DKK/NOK were established as separate currencies on August 2, 1914 and not January 1...

-t 

Thanks!

Nitpic is exactly what I'm after, I don't trust Wikipedia to be 100% right, and I don't have teh time for teh in-depth research to do it myself :-) The unit names are not used yet, but it's better to get them right before we do.  The exact date was something Wikipedia didn't have, so I'll fix those too.  Thanks!

Chinese currency symbols

Hi,

in my current KDE version (from openSUSE's KDE4 Factory repository - systemsettings identifies itself as (Version 1.0 Using KDE 4.3.80 (KDE 4.3.80 (KDE 4.4 Beta1)) "release 200"') I only see ¥ and CNY in the list of currency symbols when choosing "Chinese Yuan (CNY)". There is another very commonly used (if not the most common, when referring to the currency in English) currency symbol, that's not in the list: RMB (RenMinBi, means "People's currency"). You could also add "yuan" to the list, although that's not "official" - I don't know if it can really count as a currency symbol... but people definitely use it in texts (example: "I bought this computer for 2700 yuan"). If "yuan" gets added, the Chinese character for Yuan (Simplified Chinese: 元) should probably also get added.

Thanks for your localisation work, it's important!

Patrick.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.