Skip to content

A package to allow your class to support verbose localization.

License

Notifications You must be signed in to change notification settings

chinleung/verbose-localization

Repository files navigation

Verbose Localization

Latest Version on Packagist Build Status Quality Score Total Downloads

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.

View Methods
  • inAmharic
  • inArabic
  • inHausa
  • inHebrew
  • inMaltese
  • inSomali
View Methods
  • inCebuano
  • inFilipino
  • inHawaiian
  • inJavanese
  • inKhmer
  • inMalagasy
  • inMalay
View Methods
  • inKannada
  • inMalayalam
  • inTamil
  • inTelugu
View Methods
  • inHaitianCreole
View Methods
  • inHmong
View Methods
  • inAlbanian
  • inArmenian
  • inGreek
View Methods
  • inBelarusian
  • inBosnian
  • inBulgarian
  • inCroatian
  • inCzech
  • inLatvian
  • inLithuanian
  • inMacedonian
  • inPolish
  • inRussian
  • inSerbian
  • inSlovak
  • inSlovenian
  • inUkrainian
View Methods
  • inIrish
  • inScotsGaelic
  • inWelsh
View Methods
  • inAfrikaans
  • inDanish
  • inDutch
  • inEnglish
  • inFrisian
  • inGerman
  • inIcelandic
  • inLuxembourgish
  • inNorwegian
  • inSwedish
  • inYiddish
View Methods
  • inBengali
  • inGujarati
  • inHindi
  • inKurmanjiKurdish
  • inMarathi
  • inNepali
  • inPashto
  • inPersian
  • inPunjabi
  • inSindhi
  • inSinhala
  • inTajik
  • inUrdu
View Methods
  • inCatalan
  • inCorsican
  • inFrench
  • inGalician
  • inItalian
  • inLatin
  • inPortuguese
  • inRomanian
  • inSpanish
View Methods
  • inBasque
  • inEsperanto
View Methods
  • inJapanese
View Methods
  • inGeorgian
View Methods
  • inKorean
View Methods
  • inLao
  • inThai
View Methods
  • Mongolian
View Methods
  • inChewa
  • inChichewa
  • inIgbo
  • inSesotho
  • inShona
  • inSwahili
  • inXhosa
  • inYoruba
  • inZulu
View Methods
  • inBurmeseMyanmar
  • inSimplifiedChinese
  • inTraditionalChinese
View Methods
  • inAzerbaijani
  • inKazakh
  • inKyrgyz
  • inTurkish
  • inUzbek
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.

About

A package to allow your class to support verbose localization.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages