vria / nodiacritic-bundle
The symfony integration for nodiacritic library
Installs: 13 515
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
- symfony/framework-bundle: >=2.3
- twig/twig: ~1.23|~2.0
- vria/nodiacritic: ~0.1
Requires (Dev)
- phpunit/phpunit: 4.8.*
This package is not auto-updated.
Last update: 2024-10-26 19:27:15 UTC
README
The symfony integration for nodiacritic library - tiny library that removes all diacritical signs from characters.
##Installation
Using Composer, run:
composer require vria/nodiacritic-bundle
Add the VRiaNoDiacriticBundle to your application kernel:
// app/AppKernel.php public function registerBundles() { return array( // ... new VRia\Bundle\NoDiacriticBundle\VRiaNoDiacriticBundle(), // ... ); }
##Use
In controller:
$noDiacriticString = NoDiacritic::filter("Révolution française");
In Twig template:
{{ "Révolution française"|nodiacritic }}
As expected, the result is Revolution francaise
.
As you can see nodiacritic library is aware of German and Danish
particularities, and so is this integration. The bunble reads current locale from Request
and pass it to filter
function.
In case the desired locale is different you can pass it as a parameter:
Ceci est une phrase allemande sans caractères spéciaux: {{ "Schöne straße"|nodiacritic("de") }}
will print Ceci est une phrase allemande sans caractères spéciaux: Schoene strasse
.
You can find the article about the library in my blog.