alldigitalrewards / language-mapper
Language Mapper Library
Installs: 2 911
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^7.0|^8.0
Requires (Dev)
- phpunit/phpunit: ^7.0|^8|^9
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^3.0
- dev-master
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.0
- dev-DS-4497
- dev-DS-4062
- dev-revert-13-DS-4025
- dev-DS-4025
- dev-DS-3968
- dev-DS-3477
- dev-UpdateEnglishDisplay
- dev-DS-3250
- dev-DS-3161-v3
- dev-DS-3161-v2
- dev-DS-3161
- dev-DS-3209-remove-void
- dev-DS-3209
- dev-RemoveTypeHintBreakingTests
- dev-AllowShortCodeAndLocalesWithDashes
This package is auto-updated.
Last update: 2024-10-16 01:46:56 UTC
README
This is a Language mapper which maps a Language tag, defaulting to 'en' if not found or present
Install
Via Composer
$ composer require alldigitalrewards/language-mapper
Usage
Returns default en_US since language not found in acceptable list: $mapper = new LanguageMapper('nz_NZ'); $this->assertSame('en_US', $mapper->getLanguage()); Returns es_ES since language found in acceptable list: $mapper = new LanguageMapper('es_ES'); $this->assertSame('es_ES', $mapper->getLanguage()); You can pass in short code and/or long code with dashes $mapper = new LanguageMapper('fr'); $this->assertSame('fr_CA', $mapper->getLanguage()); $mapper = new LanguageMapper('es-ES'); $this->assertSame('es_ES', $mapper->getLanguage());
Testing
$ composer test