Package Data | |
---|---|
Maintainer Username: | nodes |
Maintainer Contact: | moru@nodes.dk (Morten Rugaard) |
Package Create Date: | 2015-11-08 |
Package Last Update: | 2020-02-14 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-04-12 03:01:51 |
Package Statistics | |
---|---|
Total Downloads: | 8,695 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 4 |
Total Forks: | 2 |
Total Open Issues: | 0 |
A package to enable usage of translation services rather than local files.
At Nodes we create a lot of stuff, which needs to be supported in multiple languages. The translation feature that comes out of the box requires a developer to change it in a local file and commit and deploy that. But we wanted to use a service where other people - clients, project managers etc. - would be able to manage translations.
This package makes it easy to create translation providers and use them genericly in your Laravel application.
Right it only comes with support for:
But we very much welcome pull requests with providers to other services.
To install this package you will need:
You must then modify your composer.json
file and run composer update
to include the latest version of the package in your project.
"require": {
"nodes/translate": "^1.0"
}
Or you can run the composer require command from your terminal.
composer require nodes/translate:^1.0
Setup service provider in config/app.php
Nodes\Translate\ServiceProvider::class
Setup alias in config/app.php
'Translate' => Nodes\Translate\Support\Facades\Translate::class
Publish config files
php artisan vendor:publish --provider="Nodes\Translate\ServiceProvider"
If you want to overwrite any existing config files use the --force
parameter
php artisan vendor:publish --provider="Nodes\Translate\ServiceProvider" --force
translate($key, $replacements = [], $locale = null, $platform = null)
translate_app($app, $key, $replacements = [], $locale = null, $platform = null)
translate_or_fail($key, array $replacements = [], $locale = null, $platform = null)
translate_app_or_fail($application, $key, $replacements = [], $locale = null, $platform = null)
translate_with_fallback($key, $fallback, array $replacements = [], $locale = null, $platform = null)
translate_app_with_fallback($application, $key, $fallback, $replacements = [], $locale = null, $platform = null)
There are two ways to handle fallbacks, if key is either missing or NStack is down and cache is invalid
By default the translate() func will use laravel's trans('nstack.' . key) as fallback, that means you can download the nstack keys and reformat them to a php array in insert the file into /ressources/lang/en/nstack.php
Use the translate_with_fallback and decide what to use
This package is developed and maintained by the PHP team at Nodes
This package is open-sourced software licensed under the MIT license