LibLocalisation by Horst Nogajski

Contains localisations for currency, language and countries.

Localisation Library for Countries, Languages and Currencies

This library contains packaged publicly available data taken from an older version of Umpirsky's Country List before it specialised just in country localisations.

Prerequisites


  • A working PW3.0.98+ installation.

Installation


Via Modules Page In Admin

  • Install using module class name of "LibLocalisation"

Usage Examples


To create a localisation for a particular locale, first create a new instance and define the locale...

$de_DE = wire('modules')->get('LibLocalisation')->setLocale('de_DE');

You can now use your locale to get information about countries, currencies and languages as they are used in that locale. For example, to output the names of various countries you use the country() method, passing in an ISO 3166-2 country code...

echo $de_DE->country('CH'); // Outputs "Schweiz" - the German for Switzerland.
echo $de_DE->country('AU'); // Outputs "Australien" - the German for Australia.
echo $de_DE->country('US'); // Outputs "Vereinigte Staaten" - ditto for the United States of America.

You can create as many instances of the module as you need and set them all up for the same, or different, locales.

To access currency data, you call the currency() method, passing in the currency code you are interested in.

echo $de_DE->currency('GBP');

This returns an array of data about GBP - localised in German...

[
digits => 2,
number => "826",
symbol => "£",
name => "Britisches Pfund Sterling"
]

Finally, you can output localised language names by calling the language() method and giving it a language code.

echo $de_DE->language('fr'); // Outputs "Französisch" - the German for French.

File structure for localisation data


The data is housed under the data/ subdirectory and is arranged by major language code. Sub locales hold specialisations of the parent language entries, and this structure prevents much repetition in the data set.

data/
  |-- ar  << 2 letter folders hold files containing localisations
  .         for the base language they represent.
  .
  .
  |-- common             - This folder holds various data common to all areas.
  .
  .
  .
  |-- en                 - This folder holds general English localisations.
  |    |-- currency.php
  |    |-- language.php
  |    \-- country.php   - This file has the country name mappings in English.
  |
  |-- en_GB
  |     \-- country.php  - This file holds the just the diffs from en/country.php country name mappings.
  |
  |-- fr                 - This folder has the French localisations.
  |    |-- currency.php
  |    |-- language.php
  |    \-- country.php
  |
  |-- fr_FR
  |     |-- language.php
  |     \-- country.php
  .
  .
  .

License(s)


Umpirsky's Country List data was used as the source for the files under the data/ directory and that project uses a MIT License. My module is also issued under a MIT license (See LICENSE.txt.)

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Twitter updates

  • ProcessWire 3.0.180 core updates– More
    18 June 2021
  • Today a new version of FormBuilder has been released in the FormBuilder support board (our 50th version) and it has a lot of interesting new features, which we’ll take a closer look at in this post— More
    11 June 2021
  • ProcessWire 3.0.179 adds great new admin theme customization tools that put you in full control over the Uikit admin styles— More
    28 May 2021

Latest news

  • ProcessWire Weekly #371
    In the 371st issue of ProcessWire Weekly we'll check out ProcessWire 3.0.180, introduce a new module called Flowti Page Serializer, highlight some recent forum posts and tutorials, and more. Read on!
    Weekly.pw / 19 June 2021
  • ProcessWire FormBuilder v50 updates
    Today a new version of FormBuilder has been released in the FormBuilder support board (our 50th version) and it has a lot of interesting new features, which we'll take a closer look at in this post.
    Blog / 11 June 2021
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK