Download the PHP package tobento/service-translation without Composer
On this page you can find all versions of the php package tobento/service-translation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tobento/service-translation
More information about tobento/service-translation
Files in tobento/service-translation
Package service-translation
Short Description Allowing you to support multiple languages within your application.
License MIT
Homepage https://www.tobento.ch
Informations about the package service-translation
Translation Service
With the Translation Service you can translate messages easily.
Table of Contents
- Getting started
- Requirements
- Highlights
- Simple Example
- Documentation
- Translator
- Create Translator
- Translate Message
- Resources
- Create Resources
- Add Resources
- Filter Resources
- Sort Resources
- Get Resources / Translations
- Files Resources
- Create Files Resources
- Directory Structure
- Supported Files
- Supporting Other Files
- Modifiers
- Pluralization
- Parameter Replacer
- Missing Translation Handler
- Translator
- Credits
Getting started
Add the latest version of the translation service running this command.
Requirements
- PHP 8.0 or greater
Highlights
- Framework-agnostic, will work with any project
- Decoupled design
Simple Example
Here is a simple example of how to use the translation service:
Documentation
Translator
Create Translator
Translator Interface
Locale Aware
Resources Aware
See also Files Resources for more details.
Modifiers Aware
See also Modifiers for more details.
Translate Message
By default, resources will be sorted by its priority!
Using specific resource
Keep in mind that named resources are only loaded on the first resource request.\ Resources with "*" named are always loaded.
Resources
Create Resources
Add Resources
You may add resources by using the add method:
add resource
add resources
Filter Resources
You may use the filter methods returning a new instance.
filter
locale
locales
name
Sort Resources
sort by priority
sort by callback
Get Resources / Translations
all
translations
:warning: You must call locale() or locales() before all() or translations() method if you have added (sub or lazy) resources, otherwise they will not get created.
Files Resources
Create Files Resources
Directory Structure
Files starting with the locale are stored as resource name. They are all fetched and merged together on the first translations request.\ Files not starting with the locale are only loaded on the first resource request. Furthermore, files named like and are merged together as resource name .
Supported Files
Currently supported files are json and php.
json
php
Supporting Other Files
You may support others files by providing your own resource factory:
Modifiers
Create Modifiers
Add Modifier
Get all modifiers
Modify message
Pluralization
Parameter Replacer
Missing Translation Handler
You may add a logger to log missing messages:
Credits
- Tobias Strub
- All Contributors
All versions of service-translation with dependencies
psr/log Version ^1.1 || ^2.0 || ^3.0
tobento/service-filesystem Version ^1.0
tobento/service-dir Version ^1.0