2017 © Pedro Peláez
 

library language

Eden language component.

image

eden/language

Eden language component.

  • Friday, November 13, 2015
  • by cblanquera
  • Repository
  • 14 Watchers
  • 0 Stars
  • 8,152 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

logo Eden Language

Build Status

====, (*1)

, (*2)

Install

composer install eden/language, (*3)

====, (*4)

, (*5)

Introduction

Languages in Eden are fairly robust, simply defined and designed to work with other translating services such as Google Translate. The follow figure shows how to set up a french translator., (*6)

Figure 1. French Translator, (*7)

//initial translations
$translations = array(
    'Hello'         => 'Bonjour',
    'How are you?'  => 'Como tale vous?');

//load up the translation   
$french = eden('language', $translations);

//you can add translations on the fly
$french->translate('I am good thank you, and you?', 'Bien mercy, et vous?');

//now echo some translations
echo $french->get('Hello'); //--> Bonjour
echo $french->get('How are you?'); //--> Como tale vous?
echo $french->get('I am good thank you, and you?'); //--> Bien mercy, et vous?

For ease of use we also made the language object accessable as an array. The next figure shows the same as Figure 1 except that it's usings arrays to manipulate the object., (*8)

Figure 2. Languages as Arrays, (*9)

//initial translations
$translations = array(
    'Hello'         => 'Bonjour',
    'How are you?'  => 'Como tale vous?');

//load up the translation   
$french = eden('language', $translations);

//you can add translations on the fly
$french['I am good thank you, and you?] = 'Bien mercy, et vous?';

//now echo some translations
echo $french['Hello']; //--> Bonjour
echo $french['How are you?']; //--> Como tale vous?
echo $french['I am good thank you, and you?']; //--> Bien mercy, et vous?

foreach($french as $default => $translation) {
    echo $translation;
}

Most commonly, websites using languages usually start and end with loading and saving translation files. Using Eden's language object through the life of the page and later saving will keep your languages file always up to date., (*10)

Note: Eden does not do the actual translating on its own. Once the file is generated and saved you should run it through a translating service., (*11)

Figure 3. Loading and Saving a Language File, (*12)

//load up a translation file
$translations = eden('file', '/path/to/french.php')->getData();
$french = eden('language', $translations);

//add to translation
$french['I am good thank you, and you?] = 'Bien mercy, et vous?';

//save back to file
$french->save('/path/to/french.php');

====, (*13)

, (*14)

API

====, (*15)

, (*16)

get

Returns the translated key. if the key is not set it will set the key to the value of the key, (*17)

Usage

eden('language')->get(string );

Parameters

  • string

Returns string, (*18)

Example

eden('language')->get();

====, (*19)

, (*20)

getLanguage

Return the language set, (*21)

Usage

eden('language')->getLanguage();

Parameters

Returns array, (*22)

====, (*23)

, (*24)

save

Saves the language to a file, (*25)

Usage

eden('language')->save(string|null $file);

Parameters

  • string|null $file - The file to save to

Returns this, (*26)

Example

eden('language')->save();

====, (*27)

, (*28)

translate

Sets the translated value to the specified key, (*29)

Usage

eden('language')->translate(*string $key, *string $value);

Parameters

  • *string $key - The translation key
  • *string $value - The default value if we cannot find the translation

Returns this, (*30)

Example

eden('language')->translate('foo', 'foo');

====, (*31)

, (*32)

Contributing to Eden

Contributions to Eden are following the Github work flow. Please read up before contributing., (*33)

Setting up your machine with the Eden repository and your fork

  1. Fork the repository
  2. Fire up your local terminal create a new branch from the v4 branch of your fork with a branch name describing what your changes are. Possible branch name types:
    • bugfix
    • feature
    • improvement
  3. Make your changes. Always make sure to sign-off (-s) on all commits made (git commit -s -m "Commit message")

Making pull requests

  1. Please ensure to run phpunit before making a pull request.
  2. Push your code to your remote forked version.
  3. Go back to your forked version on GitHub and submit a pull request.
  4. An Eden developer will review your code and merge it in when it has been classified as suitable.

The Versions

13/11 2015

dev-master

9999999-dev http://eden-php.com

Eden language component.

  Sources   Download

MIT

The Requires

 

by Christian Blanquera

library eden

13/11 2015

4.x-dev

4.9999999.9999999.9999999-dev http://eden-php.com

Eden language component.

  Sources   Download

MIT

The Requires

 

by Christian Blanquera

library eden

13/10 2015

4.0.1

4.0.1.0 http://eden-php.com

Eden language component.

  Sources   Download

MIT

The Requires

 

by Christian Blanquera

library eden

07/10 2015

v4

4.0.0.0 http://eden-php.com

Eden language component.

  Sources   Download

MIT

The Requires

 

by Christian Blanquera

library eden

24/09 2013

1.0.3

1.0.3.0 http://eden-php.com

Eden language component

  Sources   Download

MIT

The Requires

 

by Christian Blanquera

library eden

24/09 2013

1.0.2

1.0.2.0 http://eden-php.com

Eden language component

  Sources   Download

MIT

The Requires

 

by Christian Blanquera

library eden