Skip to content

Commit

Permalink
Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Azzolini committed Feb 1, 2016
0 parents commit 6c27612
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store

51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Core – Translation Extensions
====

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/caffeina-core/translation/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/caffeina-core/translation/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/caffeina-core/translation/badges/build.png?b=master)](https://scrutinizer-ci.com/g/caffeina-core/translation/build-status/master)
[![Total Downloads](https://poser.pugx.org/caffeina-core/translation/downloads.svg)](https://packagist.org/packages/caffeina-core/translation)
[![Latest Stable Version](https://poser.pugx.org/caffeina-core/translation/v/stable.svg)](https://packagist.org/packages/caffeina-core/translation)
[![Latest Unstable Version](https://poser.pugx.org/caffeina-core/translation/v/unstable.svg)](https://packagist.org/packages/caffeina-core/translation)
[![License](https://poser.pugx.org/caffeina-core/translation/license.svg)](https://packagist.org/packages/caffeina-core/translation)


## Installation

Install via [composer](https://getcomposer.org/download/):

```bash
$ composer require caffeina-core/translation
```

## Documentation

See the [wiki](https://github.com/caffeina-core/translation/wiki).


## Contributing

How to get involved:

1. [Star](https://github.com/caffeina-core/api/stargazers) the project!
2. Answer questions that come through [GitHub issues](https://github.com/caffeina-core/translation/issues?state=open)
3. [Report a bug](https://github.com/caffeina-core/translation/issues/new) that you find


Core follows the [GitFlow branching model](http://nvie.com/posts/a-successful-git-branching-model). The ```master``` branch always reflects a production-ready state while the latest development is taking place in the ```develop``` branch.

Each time you want to work on a fix or a new feature, create a new branch based on the ```develop``` branch: ```git checkout -b BRANCH_NAME develop```. Only pull requests to the ```develop``` branch will be merged.

Pull requests are **highly appreciated**.

Solve a problem. Features are great, but even better is cleaning-up and fixing issues in the code that you discover.

## Versioning

Core is maintained by using the [Semantic Versioning Specification (SemVer)](http://semver.org).


## Copyright and license

Copyright 20145 [Caffeina](http://caffeina.co) srl under the [MIT license](LICENSE.md).

<p align="center"><a href="http://caffeina.co" target="_blank" title="Caffeina - Ideas Never Sleep"><img src="https://github.com/CaffeinaLab/BrandResources/blob/master/caffeina-handmade.png?raw=true" align="center" height="65"></a></p>
30 changes: 30 additions & 0 deletions classes/Language.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* Language
*
* Localization tools.
*
* @package core
* @author [email protected]
* @version 0.1 * @copyright Caffeina srl - 2015 - http://caffeina.it
*/

class Language extends Dictionary {
use Module;
protected static $current_lang = 'en';

public static function translate($text,$params=null){
$result = static::get(static::$current_lang.'.'.strtolower($text),$text);
return $params ? Text::render($result) : $result;
}

public static function using($lang){
static::$current_lang = strtolower(trim($lang));
}

public static function load($lang, $dictfile){
ob_start(); $lang = include($dictfile); ob_end_clean();
static::merge([$lang => $dictfile]);
}
}
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "caffeina-core/translation",
"type": "core-bundle",
"description": "Translation extensions for Caffeina Core",
"keywords": ["core","translation","language"],
"homepage": "http://labs.caffeina.co/tech/core",
"version": "1.0.0",
"license": "MIT",
"authors": [
{
"name": "Stefano Azzolini",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.4",
"caffeina-core/core": "*"
},
"minimum-stability": "stable",
"autoload": {
"classmap": [ "classes/" ]
}
}

0 comments on commit 6c27612

Please sign in to comment.