VRiaNoDiacriticBundle
, (*1)
The symfony integration for nodiacritic library - tiny library that removes all diacritical signs from characters., (*2)
Installation
Using Composer, run:, (*3)
composer require vria/nodiacritic-bundle
Add the VRiaNoDiacriticBundle to your application kernel:, (*4)
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new VRia\Bundle\NoDiacriticBundle\VRiaNoDiacriticBundle(),
// ...
);
}
Use
In controller:, (*5)
$noDiacriticString = NoDiacritic::filter("Révolution française");
In Twig template:, (*6)
{{ "Révolution française"|nodiacritic }}
As expected, the result is Revolution francaise
., (*7)
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:, (*8)
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
., (*9)
You can find the article about the library in my blog., (*10)