Download the PHP package macmotp/locale without Composer
On this page you can find all versions of the php package macmotp/locale. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download macmotp/locale
More information about macmotp/locale
Files in macmotp/locale
Package locale
Short Description A curated library to handle locale in PHP
License MIT
Homepage https://github.com/macmotp/locale
Informations about the package locale
A curated library to handle locale in PHP
Simple and light PHP library that handles Countries, Languages, and Timezones
Useful for any application that needs localization.
Requirements
- PHP >= 8.2
Installation
Install the package via composer:
Usage
Create Country objects
List of basic dynamic methods
getContinent()
: it returns the continent;getName()
: it returns the name;getCapital()
: it returns the capital;getCode()
: it returns the country code (alpha2);getAlpha3Code()
: it returns the country code (alpha3);getDialCode()
: it returns the dial code;getTld()
: it returns the internet tld;getDateFormat()
: it returns the date format;getDefaultCurrency()
: it returns the default currency;getDefaultTimezone()
: it returns the default timezone;getDefaultLanguage()
: it returns the default locale language;toArray()
: it returns the object into array;
List of advanced dynamic methods
getCurrencies()
: it returns a Collection with all the currencies adopted in that country;getTimezones()
: it returns a Collection with all the timezones applied in that country;getLanguages()
: it returns a Collection with all the languages used in that country;
List of Countries in the package
Filter Countries by property
withCurrency($currencyCode)
: it returns a Collection with all the currencies adopted in that country;speaking($language)
: it returns a Collection with all the countries speaking a specific language;ofContinent($continent)
: it returns a Collection with all the countries that belong to a continent;
These methods can be chained, for example: Country::all()->ofContinent(Continent::EUROPE)->speaking(Language::ENGLISH);
Supported Locales (in order of locale code)
- Language::ARABIC = 'ar';
- Language::GERMAN = 'de';
- Language::ENGLISH = 'en';
- Language::SPANISH = 'es';
- Language::FRENCH = 'fr';
- Language::ITALIAN = 'it';
- Language::JAPANESE = 'ja';
- Language::KOREAN = 'ko';
- Language::DUTCH = 'nl';
- Language::PORTUGUESE = 'pt';
- Language::CHINESE = 'zh';
Localization
In addition to the default functions, it's possible to localize the response:
Testing
Changelog
Please see changelog for more information on what has changed recently.
Contributing
Please see contributing for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.