Download the PHP package rougin/transcribe without Composer
On this page you can find all versions of the php package rougin/transcribe. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rougin/transcribe
More information about rougin/transcribe
Files in rougin/transcribe
Package transcribe
Short Description Yet another language library for PHP
License MIT
Homepage https://github.com/rougin/transcribe
Informations about the package transcribe
Transcribe
Transcribe
is a simple localization package written in PHP in which the translated word can be retrieved easily based on the specified locale. A localization source can be from multiple .php
files or from a database connection using PDO.
Installation
Install the Transcribe
package via Composer:
Basic usage
Prior in using Transcribe
, a list of words must be provided with its specified translations (e.g., fil_PH.php
):
Once provided, specify the words in a source (e.g., FileSource
):
After creating the specified source, use the get
method from the Locale
class to get the localized word based on its keyword:
Using the setDefault
method can define the default locale. With this, there is no need to specify it when using the get
method:
Using sources
The previous example uses the FileSource
which uses .php
files in getting localized words. But Transcribe
also provides a way in getting the said localized words through a database using the PdoSource
:
When using the PdoSource
class, it can also specify the database table and its columns to be used for getting the localized words:
[!NOTE] If the required table and columns were not specified, its default values are the same from the above-example (e.g.,
locales
for table, andtype
,name
, andtext
values for the columns).
Then use the same get
method from Locale
class to get the localized word from the database table:
Creating custom sources
To create a custom source, kindly use the SourceInterface
for its implementation:
The words
method should return a list of words in an associative array format:
The specified method will be used as the reference for finding the localized word from the get
method of Locale
class.
Migrating to the v0.4.0
release
The new release for v0.4.0
will be having a backward compatibility break (BC break). With this, some functionalities from the earlier versions might not be working after upgrading. This was done to increase extensibility, simplicity and maintainbility. This was discussed in one of my blog post which also mentions Transcribe
:
I also want to extend this plan to my personal packages as well like Staticka and Transcribe. With this, I will introduce backward compatibility breaks to them initially as it is hard to migrate their codebase due to minimal to no documentation being provided in its basic usage and its internals. As I checked their code, I realized that they are also over engineered, which is a mistake that I needed to atone for when updating my packages in the future.
Please see Pull Request #1 for the files that were removed or updated in this release and the UPGRADING page for the specified breaking changes.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
Credits
License
The MIT License (MIT). Please see LICENSE for more information.