chinleung / verbose-localization
A package to allow your class to support verbose localization.
Installs: 7 803
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.1
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-11-07 08:27:17 UTC
README
A package to allow your class to support verbose localization.
Installation
You can install the package via composer:
composer require chinleung/verbose-localization
Usage
Add the ChinLeung\VerboseLocalization\HasVerboseLocalization
trait to your class and create a method getTranslationIn(string $locale)
to handle the translation of your class and get access to all the verbose methods instantly like the following example.
Suppose you have files with the translation of the text equivalent of numbers:
<?php class NumberClass { use ChinLeung\VerboseLocalization\HasVerboseLocalization; /** * Constructor of the class. * * @param int $value */ public function __construct(int $value) { $this->value = $value; } /** * Retrieve the translation in a specific locale. * * @param string $locale * @return string */ public function getTranslationIn(string $locale) : string { $translations = require __DIR__."/resources/lang/$locale/numbers.php"; return $translations[$this->value]; } }
Then you can retrieve the translations like this:
$number = new NumberClass(1);
$number->inFrench(); // 'un'
$number->inEnglish(); // 'one'
$number->inSimplifiedChinese(); // 'δΈ€'
Methods
The methods are seperated by language families which are located in src/Concerns.
Afro-Asiatic
View Methods
- inAmharic
- inArabic
- inHausa
- inHebrew
- inMaltese
- inSomali
Austronesian
View Methods
- inCebuano
- inFilipino
- inHawaiian
- inJavanese
- inKhmer
- inMalagasy
- inMalay
Dravidian
View Methods
- inKannada
- inMalayalam
- inTamil
- inTelugu
French Creole
View Methods
- inHaitianCreole
Hmong-Mien
View Methods
- inHmong
Indo-European
View Methods
- inAlbanian
- inArmenian
- inGreek
Balto-Slavic
View Methods
- inBelarusian
- inBosnian
- inBulgarian
- inCroatian
- inCzech
- inLatvian
- inLithuanian
- inMacedonian
- inPolish
- inRussian
- inSerbian
- inSlovak
- inSlovenian
- inUkrainian
Celtic
View Methods
- inIrish
- inScotsGaelic
- inWelsh
Germanic
View Methods
- inAfrikaans
- inDanish
- inDutch
- inEnglish
- inFrisian
- inGerman
- inIcelandic
- inLuxembourgish
- inNorwegian
- inSwedish
- inYiddish
Indo-Iranian
View Methods
- inBengali
- inGujarati
- inHindi
- inKurmanjiKurdish
- inMarathi
- inNepali
- inPashto
- inPersian
- inPunjabi
- inSindhi
- inSinhala
- inTajik
- inUrdu
Italic
View Methods
- inCatalan
- inCorsican
- inFrench
- inGalician
- inItalian
- inLatin
- inPortuguese
- inRomanian
- inSpanish
Isolate
View Methods
- inBasque
- inEsperanto
Japonic
View Methods
- inJapanese
Kartvelian
View Methods
- inGeorgian
Koreanic
View Methods
- inKorean
Kra-Dai
View Methods
- inLao
- inThai
Monogolic
View Methods
- Mongolian
Niger-Congo
View Methods
- inChewa
- inChichewa
- inIgbo
- inSesotho
- inShona
- inSwahili
- inXhosa
- inYoruba
- inZulu
Sino-Tibetan
View Methods
- inBurmeseMyanmar
- inSimplifiedChinese
- inTraditionalChinese
Turkic
View Methods
- inAzerbaijani
- inKazakh
- inKyrgyz
- inTurkish
- inUzbek
Uralic
View Methods
- inEstonian
- inFinnish
- inHungarian
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email hello@chinleung.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
PHP Package Boilerplate
This package was generated using the PHP Package Boilerplate.