(Quick Reference)

2 Configuration - Reference Documentation

Authors: Matouš Kučera

Version: 1.0

2 Configuration

There are few configuration options for the plugin:
NameDefaultDescription
grails.plugin.countrySelector.messageSource.useOnlyCustomfalseTrue if only custom i18n country settings should be used. See more in Countries Customization in i18n.

2.1 Countries i18n

The plugin is dependent on i18n Grails plugin and allows to set all language/location properties needed for country selector. Therefore, simply changing the user locale can change the country selector behavior.

It allows to set-up following properties for each country:

  1. Country Code - Plugin uses ISO 3166-1 alpha-3 codes for countries but you can set your own. Country codes are the values returned when the user submit the country selector. They could be easily mapped to domain class property. Examples: GBR , DEU , etc.
  2. Country Name - It is the actual country name the user sees in autocomplete. Examples: United Kingdom , Germany , etc.
  3. Country Alternatives - Alternative strings which should be used for autocomplete. When the user starts typing an alternative he should receive a proper country name. Examples: GB Great Britain England UK Wales Scotland Northern Ireland for United Kingdom, DE Bundesrepublik Deutschland for Germany.
  4. Relevancy - The relevancy specifies the order of results in autocomplete. Country selector sorts the countries by their relevancy first (higher relevancy ~ higher position in autocomplete) and than alphabetically. Examples: United States relevancy 3.5 , United Kingdom relevancy 2.5

Having these properties in i18n allows to set different values for different locale. It allows for example to set a different relevancy for different locale, i.e. Sweden would have higher relevancy than Switzerland in Sweden locale but this would be vice versa for Switzerland locale.

2.1.1 Countries Customization in i18n

The structure of i18n country properties is following:

org.grails.plugin.countrySelector.CZE=Czech Republic
org.grails.plugin.countrySelector.CZE.alternatives=CZ Česká Ceska
org.grails.plugin.countrySelector.CZE.relevancy=1.5

org.grails.plugin.countrySelector.DNK=Denmark org.grails.plugin.countrySelector.DNK.alternatives=DK Danmark org.grails.plugin.countrySelector.DNK.relevancy=1.5

The country code is the last part of the first property key, the value specifies the country name. Alternatives are space separated names. Similarly, relevancy is used for country position in the country selector.

By default custom property files are merged with the plugin specified. You can set all country specifiactions (name, alternatives, relevancy) or just few of them. The custom specification has higher priority during merging. New countries could be defined if it is required.

You can also decide to use your custom i18n settings by default (for example, this can be used when you would like to define custom country codes, or just reduce the number of possible countries). Set following in Config.groovy

grails.plugin.countrySelector.messageSource.useOnlyCustom = true

2.1.2 Supported Languages

English ang Germany are the only one supported languages right now. The whole setup of country names, alternative and relevancy is in i18n/messages.properties file of the plugin core.