Hey
I was wondering that some common/related fields could be added to the list of countries for some more functionality.
With(out) the original goal of the module in mind, i've thought on what exactly could be added and how.
For the matters of keeping the ideas tied together, i'm starting a debate here covering them.

(International Phone) Calling Code

Countries only.
This one is relatively simple. A single field named Calling Code.
example,
USA -> +1
PT -> +351

http://en.wikipedia.org/wiki/List_of_country_calling_codes#Complete_listing

related modules:
http://drupal.org/project/phone
http://drupal.org/project/cck_phone

Nationality/Demonym

Meaning,
FR/France -> French
IT/Italy -> Italian
PT/Portugal -> Portuguese
UK/United Kingdom -> British
US/United States -> American
etc

Wikipedia has a large list of nationalities (nations and countries) and other demonyms, covering:

  • Continents
  • Countries and nations
  • Cities
  • Regions, States, Territories
  • Subcontinental regions
  • etc

These are split into Adjectivals (singular) and Demonyms (plural).
Some of the records also have colloquial terms, and many of them, have more than one form for Adjectivals and Demonyms.
These records are unique. AFAIK, countries and other places don't share demonyms with each others.

Now that we got a bit overwhelmed, i'll simplify:

  • Include only Countries and Nations, so no continents, cities, etc - as to keep consistency with the records being stored - OR NOT - see next field
  • Include only Adjectivals (singular) and Demonyms (plural), no colloquial terms (keep the module formal and only use the most important information). These could be named and referred as Adjective, short for Country Adjective/Adjectivals and Demonym, short for Country Demonym/Demonyms
  • Include only one Adjectival and Demonym per country/record (the preferred) - OR - make the field have multiple values (the preferred as top most)

http://en.wikipedia.org/wiki/Nationality
http://en.wikipedia.org/wiki/Demonym
http://en.wikipedia.org/wiki/List_of_adjectival_and_demonymic_forms_of_p...

Places

As described above and in wikipedia, there are many kinds of places.
Countries could be extended to support them:

  • Continents
  • Countries and nations
  • Cities
  • Regions, States, Territories
  • Subcontinental regions

Being the Continents, Regions, States, Territories and Cities the most important after Countries and Nations.
How to achieve this? Add a field to the countries entity that describes the type of Place with a select list.
So Japan would be a Country, New York would be a City, Africa a Continent and Algarve a Region.

The places could be referenced (entityreference) to each other to support tree-like filtering/display:
Earth -> Asia -> Russia -> Central Federal District -> Moscow

Filtering for the fields and other usages would have to have option to limit by level, to be suitable for all applications.

This probably would mean that the module would need a name change. More on that later.

http://en.wikipedia.org/wiki/Lists_of_countries_and_territories

notes:
the fields described from now on could be in new entities related to Countries using entityreference... or be simple fields attached to countries.

Internet Top-Level Domain Names

Why new entity + reference?
Countries and some regions, some topics as well.
Can include cities and enterprises in the future.
And some special fields not particularly related to countries/places.

Could be achieved as a sub-module bundled with Countries/Places, or be it's own module.

Fields:

  • TLD
  • type of TLD (general, cc, international, etc)
  • sub-TLDs (.org.uk, .co.uk) with multiple value fields, reference or multiple records per TLD
  • TLD description
  • and reference to country/place

http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains

Currencies

Why new entity + reference?
Countries only. Think Euro (€): multiple countries, same currency.
And the special fields.

Could be achieved as a sub-module bundled with Countries/Places, or be it's own module.

Fields:

  • Currency name
  • Sign
  • ISO code
  • Fractional Unit (optional)

http://en.wikipedia.org/wiki/List_of_circulating_currencies

The Currency modules in Drupal have gone mia.
http://drupal.org/project/currency_cck
http://drupal.org/project/money

Languages

Why new entity + reference?
Countries only. multiple countries, same language. sub-languages.
and special fields.

Could be achieved as a sub-module bundled with Countries/Places, or be it's own module.
Similar to Nationalities, with one caveat - one country can have more than one language.

Possible fields:

  • Language name
  • Language code (as used in drupal and other systems)
  • Language family?
  • Writing system?
  • ISO 639-1?
  • ISO 639-2?
  • ISO 639-3?

ISO 639-1 for example, specifies pt for portuguese, but European Portuguese (Portugal), is pt-pt, as used in drupal.

http://en.wikipedia.org/wiki/Language
http://en.wikipedia.org/wiki/List_of_official_languages

found this interesting module:
http://drupal.org/project/languagefield

Flags/Icons

already on its own module.
http://drupal.org/project/countryicons

http://en.wikipedia.org/wiki/Gallery_of_sovereign-state_flags

Name change

I thought on Places as a logical name change... but then i thought on the other possible fields/related entities...
Maybe something more universal, like Places Metadata, International Metadata, etc

Sorry for deviating alot from the original purpose of the module!!
These are just some ideas.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lpalgarvio’s picture

somewhat related module:
http://drupal.org/project/place

Alan D.’s picture

Somewhat related:

Countries regions

This is an overwrite of the core taxonomy system to allow it to handle large data sets, although internally the data would be best stored in a data structure designed for millions of records. Country remains the top level entity (so Black Sea kinda doesn't really fit the model), and then there are 13 "suggested" sub-regions

Countries Additional Codes

A quick hack at extending the module to provide a small collection of additional codes for the module

lpalgarvio’s picture

great work alan!
i'll look around and try these when i get some free time =)

johnv’s picture

This is a great idea, to serve as a multi-country 'data repository'.
What you describe is a 'locale' field.
In some discussions with the multilingual team, they unfortunately use 'locale' to be language-only, not currency etc.

This could make the UX truely user-centric,
For currencies, begian price is 9,9€, Dutch price is €9,90 (location of €, trailing zero)
Language is a multi-value field IMO.

Great initiative!

jelo’s picture

I would absolutely love to see this move forward. I am currently working on a site that evolves around countries and it seems that we need a lot of modules right now to get some generic basic country information such as language, regions, currency etc. included. It would be great if you could just install one module (maybe with a couple of submodules) that provides these datasets automatically, maybe hooking into a webservice such as geonames as well. I would vote for keeping as much as possible with existing ISO standards.

This could be extremely valuable for many other modules, such as location, commerce, address fields, webforms.

Alan D.’s picture

Status: Active » Needs work
FileSize
10.19 KB

I think that nationalities is about the only property that I would want to add to the core table. The supplied patch adds this, and provides the option as a field, or more precisely it provides the option to select name, official name or nationality for the field option labels.

But only two nationalities are added so far, AU and NZ!

Alan D.’s picture

Status: Needs work » Needs review
FileSize
10.21 KB

minor error. Needs work until the nationalities are populated, but running through the tests :)

Status: Needs review » Needs work

The last submitted patch, countries-1700684-7-Nationalities-fix-field-settings.patch, failed testing.

Alan D.’s picture

Status: Needs work » Needs review
FileSize
45.13 KB

Looks like test bot is going to reject the CSV :(

However, I'd love any feedback. Data is approx 97% complete, taken from a few sources, exceptions have "NAME, of" or "NAME, of the" suffixed to fill the gaps.

Status: Needs review » Needs work

The last submitted patch, countries-1700684-9-Nationalities-fix-field-settings.patch, failed testing.

olteanu5000’s picture

For the patch in #9 I had error on install. Default was needed for nationality field in schema. I also thought it would be good if I added the nationality in the admin_overview. Please consider the attached patch.

Alan D.’s picture

Version: 7.x-2.0-beta2 » 7.x-2.x-dev
FileSize
46.33 KB

Thanks George for that catch. I have added to both the main schema and the update.

This includes views integration and is ready to push with a single positive review. We have been using this on a site alongside a standard country field for the last month without issues on a profile2 bundle, the most problematic of the common entites.

johnv’s picture

Status: Needs work » Needs review
FileSize
29.25 KB

These are my test results:
Part 1: 'module update'
- I applied the patch without problems. I'll set the status to 'needs review' for official evidence.
- Ran update.php, and presented me with 2 'countries' updates. (My version was "7.x-2.1")
- The update instructed me to go to the import page, which shows the to-do changes. (See attached image)
-- It tells me to update the nationality and name for every country, which is fine. (every box is ticked)
-- It tells me to enable every country, which in NOT fine. (every box is ticked again.)
Only the 'nationality' option should be checked, and the 'change name'. But NOT the 'enable country'.

Perhaps the case of a 'normal country update' should be tested, after enabling the nationality field.

johnv’s picture

Part 2: 'data import'.
2.1: I imported the data, after unchecking the 'enable country', and I got 3 messages (The errors might have been caused by other patches. I'm testing D7.22):
Red: "Warning: Invalid argument supplied for foreach() in drupal_array_merge_deep_array() (line 2078 of ..\includes\bootstrap.inc)."
Green: "Status message The updated countries were: Afghanistan, ..."
Yellow: Skipped GQ due to duplicate fields in:" (So, no explanation after the double colon)

2.2: I reviewed the countries overview list:
- no nationality in the list!
I viewed/edited a country:
- that's OK, the nationality can be viewed, edited, saved, and viewed again.

johnv’s picture

Status: Needs work » Needs review
FileSize
13.29 KB

Part 3: "Add a nationality field to a contact/user, and show that information in a view."

1. Add a Nationality field to the Contact Node Type.
- I hoped to see a 'Field' of type 'nationality'. Alas.., so I added a Country field with title "Nationality"
- No widget for Nationality (but 10 other options.)
- No formatter for Nationality

2. Edit a Contact.
- This is not OK, but it is expected, as a result of the previous step: I can only enter a Country, not a Nationality.

3. Amend a View of contacts. (option 1: directly)
- Add the field 'nationality'. No nationality formatter.
This may be OK, since a Relationship is needed. Needs documentation!

3. Amend a View of contacts. (option 2: via a relationship)
- Add a relationship to Country: Field: Country (field_country) Appears in: ... Also known as: Content: Country (field_country), Taxonomy term: Country (field_country).
(On a side note: I didn't realize that Countries is/emulates a Taxonomy term..)
- Add a field ("country from field_country") which has the lael: "Countries: Nationality"
--> There is no Formatter. (This is expected after the results of the previous step)
- Save and show the View.
--> The field nationality can be seen via a relationship, not directly.
(See attached screendump)

johnv’s picture

Status: Needs review » Needs work

Part 4: data assessment.

De data 'Nationality' is not correct. The nationality is an adverb, not a Noun, (at least in Dutch).
Perhaps the datasource was not complete, or converted via a machine?
"I am from the Netherlands, I have the Dutch nationality, hence I am a Duchtman."

These are the result for 5 countries I'm familiar with:
NL: Netherlander (This word does not exist. The word should be Dutchman, but the nationality must be Dutch)
BE: Belgian =OK
DE: German =OK
LU: Luxembourger (This word DOES exist (according Wiki), but it is not a nationality.
FR: French =OK
For this topic one might rely on crowd sourcing. This was the first contribution!

Alan D.’s picture

Status: Needs review » Needs work

Awesome review!

#13 - Was by design, but I can see your point. We use this for a couple of sites that only have a small subset enabled and this was a pain for the one we ran this on.

So two issues:
a) To directly run the import to populate the nationalities column. Single bulk update should be fine non-batched.

b) The import has no memory of past imports, so it compares with the original CSV file. Maybe some JScript options to toggle what options are set, falling back to non-JScript that requires users to un-check maybe. See #2017745: JScript import options to select what columns to import (no work has been done yet)

#14

a) There must be an error in the duplicate code. I probably have never tested having more than one duplicate at a time and there are possible errors in this code (used twice like this):

      if ($duplicates = country_duplicate_field_check($country)) {
        $duplicates = array_unique(drupal_array_merge_deep_array($duplicates));

Firstly, array_unique() should be redundant here, as is drupal_array_merge_deep_array() afaict

b) I wonder if the schema needs flushing or something. If you still have the test site, what does re-running the import do?

#15

I'll take a look at the code duplication in creating a new field type, but I think that it would be much less as per the current implementation.

1a) These are the only widgets I get:

Check boxes/radio buttons
Select list
Countries by continent

1b) For the formatters, "Default" toggles between Name / Nationality. I guess that this should stay but two new options should be added, Name and Nationality. Does Nationality integrate with Country flags (from the screenshot, I am guess it doesn't)

2) You got this by selecting something other than Default?

3) Yep, by design. I think that this is mentioned somewhere, project page maybe, but there is a way to note this in the view too if you select the only available option without the relationship.

So this leads to #2017805: Make the view relationship more obvious to users

"On a side note: I didn't realize that Countries is/emulates a Taxonomy term.." Nope. You have a country field there :)

#16

Things need to be gender neutral here. Based off a client supplied list with gaps filled in from here:

http://publications.europa.eu/code/en/en-5000500.htm

So Luxembourgish instead of Luxembourger ;)

Alan D.’s picture

So tasks here are:

1) Direct import of country nationalities

2) Check if field schema flush is needed

3) Provide alternative to the Default field for Nationality and Name

4) Check Country Flag integration

5) Double check the data

#2 is a definite show stopper

Other issues raised:
#2017745: JScript import options to select what columns to import
#2017805: Make the view relationship more obvious to users
#2017825: Multiple duplicates in imports may cause PHP warnings and incomplete messages

johnv’s picture

It was a pleasure to test this. Thanks for your extensive answer.

Ad #13: 'too may checkboxes' I'd change the import process to process ALL CHANGES automatically. No human interference needed (like most module updates). The only problem is to wether or not enable the NEW IMPORTS (countries). I think the following would work in most situations: "When all countries are enabled, import them automacally. If not, do not enable them."

Ad #14-2.2: 'no nationality on overview list' I've clarified the comment at bit. I'm not sure if you understand. Even after refreshing all caches, te countries overview list, does not show a 'nationality' column.

Ad 15.1a: no nationality widget perhaps I wasn't looking good enough, or perhaps i needed to flush caches, but the widget is OK.

Ad 15.1b: no nationality formatter I still cannot find a subsetting for the 'Default' formatter. OTOH, when I choose "Country icon", I can select nationality.
Ad 15.2: the same goes for a formatter in a View.

Ad 16: OK, never knew that "Netherlander" exists. (Or Luxembourgish :-) )

Alan D.’s picture

"countries overview list" doesn't show this by design, but you can add this if you want:

  $columns = variable_get('countries_admin_overview_columns',
    array(
      'iso3' => t('ISO alpha-3 code'),
      'numcode' => t('ISO numeric-3 code'),
      'continent' => t('Continent'),
      'official_name' => t('Official name'))
  );

I can look at adding this too by default ;)

"subsetting for the 'Default' formatter" there are none, it should automatically pick up the nationality column if the title column is nationality. I guess this should be clearer in the field settings. Plus notes in the readme.txt

DrupalGideon’s picture

Hello, is there any update on this?

I would really like to see Nationality as part of this module so I can have this as a field to simply say I am "British".

I am working on a site with lots of people that will be a content type (using the Schema.org module and the Person content type provided) and one of the fields I want to add is Nationality as that has an entry in http://schema.org/Person

Anything I can do to get this update out into a new release?