netcarver Posted September 18, 2018 Share Posted September 18, 2018 A very simply library that quickly allows localisation of country, language and currency names into various locales. It's based on the data from Umpirsky's country-list project. I started writing this back in 2014 but have finally got around to publishing it. I hope this is of use to some of you. 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-1 2alpha 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 3-letter 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 2 letter language code. echo $de_DE->language('fr'); // Outputs "Französisch" - the German for French. Getting the Module... You can view the project on Github or in the module repository. 9 Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 21, 2018 Share Posted September 21, 2018 I'm not sure how much you intend to further work on it, but https://github.com/unicode-cldr might also be a nice source for information. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now