Jump to content

KDE Core/ISO Codes: Difference between revisions

From KDE Community Wiki
Jlayt (talk | contribs)
Jlayt (talk | contribs)
No edit summary
Line 7: Line 7:
== ISO 3166 Country Code ==
== ISO 3166 Country Code ==


You can browse [http://git.debian.org/?p=iso-codes/iso-codes.git;a=blob;f=iso_3166/iso_3166.xml the iso-codes ISO 3166 xml file]. The format provides for both official and unofficial/common names
The iso-codes file for ISO 3166 contains two sections of the [http://www.iso.org/iso/country_codes.htm ISO Country Code standard]:
* [http://www.iso.org/iso/country_codes/background_on_iso_3166.htm ISO 3166-1 Country Codes]
* [http://www.iso.org/iso/country_codes/background_on_iso_3166/iso_3166-3.htm ISO 3166-3: Code for formerly used names of countries]
 
You can browse [http://git.debian.org/?p=iso-codes/iso-codes.git;a=blob;f=iso_3166/iso_3166.xml the iso-codes ISO 3166 xml file] in Debian's git repository.
 
The format provides for both official and unofficial/common names


The iso-codes project xml format is as follows:
The iso-codes project xml format is as follows:
Line 54: Line 60:
http://translationproject.org/domain/iso_3166.html
http://translationproject.org/domain/iso_3166.html


== iso-codes Change Required ==
=== iso-codes Change Required ===


May need to review unofficial names to see if close enough match to ours.
May need to review unofficial names to see if close enough match to ours.


== KDE Changes Required ==
=== KDE Changes Required ===


* Add KLocale::countryCodes() that returns a QList<QString> of all Country Codes loaded from the iso-codes xml file.  Returns correct uppercase format.
* Add KLocale::countryCodes() that returns a QList<QString> of all Country Codes loaded from the iso-codes xml file.  Returns correct uppercase format.
Line 69: Line 75:
=== Country Code Format Conversion ===
=== Country Code Format Conversion ===


== ISO 3166-2 Country Region Code ==
A number of apps in KDE may need to convert between the different code formats, i.e. EXIV2 stores the country code using the Alpha3 code.  As the iso-codes file provides all the code formats we can provide conversion tools.  We can either add an extra parm to all the country code api calls to allow any code format to be used, but I think this would just confuse issues.  We should stick with a single format as standard, and just provide a single api call to convert the codes.
 
== ISO 3166-2 Country Subdivision Code ==
 
The iso-codes file for ISO 3166 contains two sections of the [http://www.iso.org/iso/country_codes.htm ISO Country Code standard]:
* [http://www.iso.org/iso/country_codes/background_on_iso_3166/iso_3166-2.htm ISO 3166-2 Country subdivision code]


== ISO xxx Language Codes ==
== ISO xxx Language Codes ==


== ISO xxx Currency Codes ==
== ISO xxx Currency Codes ==

Revision as of 19:37, 15 April 2011

ISO Codes in KDE

KDE uses ISO standard codes in a number of places, primarily the Country Code, Language Code and Currency Code in KLocale. Currently KDE maintains our own data files for these codes and our own translations which imposes a maintenance burden to keep the codes and translations up to date.

The Debian iso-codes project maintains a package that includes xml files of various ISO Codes and translations for them in po files. This project is well maintained and regularly updated and is used by many projects and distro's for this. It would make sense to adopt iso-codes as the source for our codes and translations.

ISO 3166 Country Code

The iso-codes file for ISO 3166 contains two sections of the ISO Country Code standard:

You can browse the iso-codes ISO 3166 xml file in Debian's git repository.

The format provides for both official and unofficial/common names

The iso-codes project xml format is as follows:

<!DOCTYPE iso_3166_entries [
        <!ELEMENT iso_3166_entries (iso_3166_entry+, iso_3166_3_entry*)>
        <!ELEMENT iso_3166_entry EMPTY>
        <!ATTLIST iso_3166_entry
                alpha_2_code            CDATA   #REQUIRED
                alpha_3_code            CDATA   #REQUIRED
                numeric_code            CDATA   #REQUIRED
                common_name             CDATA   #IMPLIED
                name                    CDATA   #REQUIRED
                official_name           CDATA   #IMPLIED
        >
        <!ELEMENT iso_3166_3_entry EMPTY>
        <!ATTLIST iso_3166_3_entry
                alpha_4_code            CDATA   #REQUIRED
                alpha_3_code            CDATA   #REQUIRED
                numeric_code            CDATA   #IMPLIED
                date_withdrawn          CDATA   #IMPLIED
                names                   CDATA   #REQUIRED
                comment                 CDATA   #IMPLIED
        >
]>

Some example entries are:

        <iso_3166_entry
                alpha_2_code="AF"
                alpha_3_code="AFG"
                numeric_code="004"
                name="Afghanistan"
                official_name="Islamic Republic of Afghanistan" />
        <iso_3166_3_entry
                alpha_4_code="YUCS"
                alpha_3_code="YUG"
                numeric_code="891"
                date_withdrawn="1993-07-28"
                names="Yugoslavia, Socialist Federal Republic of" />


Translation Status

http://translationproject.org/domain/iso_3166.html

iso-codes Change Required

May need to review unofficial names to see if close enough match to ours.

KDE Changes Required

  • Add KLocale::countryCodes() that returns a QList<QString> of all Country Codes loaded from the iso-codes xml file. Returns correct uppercase format.
  • Add KLocale::countryName() taking a country code, name type (official/unofficial name) to return, and a language code to translate into. Default values to return current locale country name in informal format for current language. Loads name translations from the iso-codes .po files
  • Add KLocale::countryNames() that returns a QList<QPair<QString,QString>> of all Country Codes and their Names in requested format and langauge.
  • Modify KLocale::allCountriesList() to call countryCodes() and return as lowercase. Add C value. Mark as deprecated.
  • Modify KLocale::countryCodeToName() to countryName(). Mark as deprecated.
  • Modify kde-runtime/l10n/ *.desktop files to remove the Name field and their translations, probably rename from .desktop to .locale or similar if doesn't break some implied API guarantee.

Country Code Format Conversion

A number of apps in KDE may need to convert between the different code formats, i.e. EXIV2 stores the country code using the Alpha3 code. As the iso-codes file provides all the code formats we can provide conversion tools. We can either add an extra parm to all the country code api calls to allow any code format to be used, but I think this would just confuse issues. We should stick with a single format as standard, and just provide a single api call to convert the codes.

ISO 3166-2 Country Subdivision Code

The iso-codes file for ISO 3166 contains two sections of the ISO Country Code standard:

ISO xxx Language Codes

ISO xxx Currency Codes