2017 © Pedro Peláez
 

library language

Avalon Language component.

image

avalon/language

Avalon Language component.

  • Saturday, April 7, 2018
  • by Nirix
  • Repository
  • 2 Watchers
  • 0 Stars
  • 847 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

Avalon - Language Package

This package makes translating easy., (*1)

Installation

This package can be installed via composer:, (*2)

composer require avalon/language

Usage

use Avalon\Language;

// Create a new translation
$myLanguage = new Language(function ($t) {
    $t->name    = 'My Language';
    $t->locale  = 'en_AU';

    // The index is what we use to fetch the string value
    $t->strings = [
        'my_string_index' => 'My String Value',
        'test_x' => 'Test {1}',
        'hello_x' => 'Hello {username}',
        'x_tickets' => "{plural:{0}, {{0} ticket|{0} tickets}}",
    ];
});

// Set our language as the current language to use by passing the `locale` value
Language::setCurrent('en_AU');

// Translate some stuff
Language::translate('my_string_index'); // => 'My String Value'
Language::translate('test_x', ['Hello']); // => 'Test Hello'
Language::translate('hello_x', ['username' => 'Admin']); // => 'Hello Admin'
Language::translate('x_tickets', [1]); // => '1 ticket'
Language::translate('x_tickets', [2]); // => 2 tickets'

The Versions

07/04 2018

dev-master

9999999-dev

Avalon Language component.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

by Avatar Nirix

avalon translations language component