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, Currencies, 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 (string);getName()
: it returns the name (string);getCapital()
: it returns the capital (string);getCode()
: it returns the country code (alpha2) (string);getAlpha3Code()
: it returns the country code (alpha3) (string);getDialCode()
: it returns the dial code (string);getTld()
: it returns the internet tld (string);getDateFormat()
: it returns the date format (string);getFlag()
: it returns the flag code (string);getDefaultCurrency()
: it returns the default currency (objectMacmotp\Currency
);getDefaultTimezone()
: it returns the default timezone (objectMacmotp\Timezone
);getDefaultLanguage()
: it returns the default locale language (objectMacmotp\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
usingCurrency($currencyCode)
: it returns a Collection with all the currencies adopted in that country;usingLanguage($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)->usingLanguage(Language::ENGLISH);
Localization
In addition to the default functions, it's possible to localize the response. By default, English is used as primary locale.
Supported Locales
Locale::ARABIC = 'ar'
;Locale::GERMAN = 'de'
;Locale::ENGLISH = 'en'
;Locale::SPANISH = 'es'
;Locale::FRENCH = 'fr'
;Locale::HINDI = 'hi'
;Locale::HUNGARIAN = 'hu'
;Locale::INDONESIAN = 'id'
;Locale::ITALIAN = 'it'
;Locale::JAPANESE = 'ja'
;Locale::KOREAN = 'ko'
;Locale::MALAY = 'ms'
;Locale::DUTCH = 'nl'
;Locale::PORTUGUESE = 'pt'
;Locale::ROMANIAN = 'ro'
;Locale::RUSSIAN = 'ru'
;Locale::TAMIL = 'ta'
;Locale::CHINESE = 'zh'
;
Flags
In addition to the source code, you can find a set of SVG flags here.
These icons are tight to the getFlag()
method, and they are associated also with Currencies and Languages.
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.