Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dees040/loca
Localization class for easy translation management.
https://github.com/dees040/loca
Last synced: about 4 hours ago
JSON representation
Localization class for easy translation management.
- Host: GitHub
- URL: https://github.com/dees040/loca
- Owner: dees040
- Created: 2015-11-19T09:17:56.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-21T13:46:51.000Z (almost 9 years ago)
- Last Synced: 2024-04-23T15:21:06.457Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Loca
====**README will be fully filled after development of the class.**
Created a class for handling translations. I though maybe somebody finds this useful.
Table of contents
-----------------
* [Installation](#installation)
* [Configuration](#configuration)
* [Usages](#usages)
* [Examples](#examples)Installation
------------Install the latest version using composer:
```
composer require dees040/loca
```Make sure you require the autoload.
Configuration
-------------Use ```Loca::prepare()``` to configure the class.
prepare() takes one argument which is an array.
**Options:**
- 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:**
```
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:
```
/languageDirectory
/en
app.php
/fr
app.php
```All language files simply return an array of keyed strings. For example:
```
'Welcome to our application.'
];```
At this moment you can call a translation:
```
Loca::translate('app.welcome');
```Which outputs: Welcome to our application.
Examples
--------None