2017 © Pedro Peláez
 

library loca

Localization class for easy translation management.

image

dees040/loca

Localization class for easy translation management.

  • Saturday, November 21, 2015
  • by dees040
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Loca

README will be fully filled after development of the class., (*1)

Created a class for handling translations. I though maybe somebody finds this useful., (*2)

Table of contents

Installation

Install the latest version using composer:, (*3)

composer require dees040/loca

Make sure you require the autoload., (*4)

Configuration

Use Loca::prepare() to configure the class., (*5)

prepare() takes one argument which is an array., (*6)

Options:, (*7)

  • locale (string): The country code of the main language to use.
  • fallbackLocale (string): The country code of the fallback language to use.
  • langDir (string): The full path to the directory which contains the translations.

Example:, (*8)

Loca::prepare([
    'locale' => 'fr',
    'fallbackLocale' => 'en',
    'langDir' => '/var/www/Loca/resources/languages',
]);

Usages

Language strings are stored in files within the specified directory. Within this directory there should be a subdirectory for each language supported by the application:, (*9)

/languageDirectory
    /en
        app.php
    /fr
        app.php

All language files simply return an array of keyed strings. For example:, (*10)


<?php return [ 'welcome' => 'Welcome to our application.' ];

At this moment you can call a translation:, (*11)

Loca::translate('app.welcome');

Which outputs: Welcome to our application., (*12)

Examples

None, (*13)

The Versions

21/11 2015

dev-master

9999999-dev https://github.com/dees040/loca

Localization class for easy translation management.

  Sources   Download

MIT

locale localization loca