Download the PHP package that0n3guy/transliteration without Composer
On this page you can find all versions of the php package that0n3guy/transliteration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download that0n3guy/transliteration
More information about that0n3guy/transliteration
Files in that0n3guy/transliteration
Package transliteration
Short Description Transliteration provides one-way string transliteration (romanization) and cleans text by replacing unwanted characters.
License MIT
Informations about the package transliteration
Transliteration - Laravel 4, 5, 6, 7, 8, 9 & 10 text cleaning Package
Transliteration provides one-way string transliteration (romanization) and cleans text by replacing unwanted characters.
...it takes Unicode text and tries to represent it in US-ASCII characters (universally displayable, unaccented characters) by attempting to transliterate the pronunciation expressed by the text in some other writing system to Roman letters.
This adapts the module from https://drupal.org/project/transliteration for use with Laravel.
Features
- Transliterate text to US-ASCII characters
Why use this?
- I use this for filename on uploads. See this image:
*
- I use this with Andrew Elkins's Cabinet
Quick start
Install the package via Composer:
composer require that0n3guy/transliteration
Depending on your version of Laravel, you should install a different version of the package.
Laravel Version | Package Version |
---|---|
10.0 | ^2.0 |
9.0 | ^2.0 |
8.0 | ^2.0 |
7.0 | ^2.0 |
6.0 | ^2.0 |
5.0 | ^2.0 |
4.0 | ^1.0 |
In your config/app.php
add 'That0n3guy\Transliteration\TransliterationServiceProvider'
to the end of the $providers
array
How to use
Simply call the Transliteration class:
This would return test_r_is_true
Set a language
You can optionally set a Optional ISO 639 language code. Do it like so:
This would return testing_Japanese_Ri_Ben_Yu_
.
How to use to rename file uploads (sanitize them)
This is an old example, but still relevant. It uses Cabinet which I don't really recommend using anymore since there are better options.
Add something like:
To your Upload controller. For example. I added it to my UploadController.php and my store() method looks like so:
Example how to use with octobercms
-
Create a plugin, for this example I'll call it
that0n3guy.drivers
. You can see documentation here: https://octobercms.com/docs/console/scaffolding#scaffold-create-plugin -
Add a bootPackages method to your
Plugin.php
as per the instructions here (copy/paste it straight from that page): https://luketowers.ca/blog/how-to-use-laravel-packages-in-october-cms-plugins/ - Add
that0n3guy/transliteration
to your plugins composer.json file:
Create a config file in your plugins config folder (create this folder) just like https://luketowers.ca/blog/how-to-use-laravel-packages-in-october-cms-plugins/. File structure example:
The config file should contain:
Now you can use transliteration facade anywhere in your octobercms php code (like in the docs above).