Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (21 sloc) 722 Bytes
<?php
namespace Grav\Plugin\Shortcodes;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
class TranslitShortcode extends Shortcode
{
public function init()
{
$this->shortcode->getHandlers()->add('translit', function(ShortcodeInterface $sc) {
$result = '';
if (class_exists('\Transliterator')) {
$content = $sc->getContent();
$rule = $sc->getParameter('rule', 'Any-Latin; Latin-ASCII');
$transliterator = \Transliterator::create($rule);
if ($transliterator) {
$result = $transliterator->transliterate($content);
}
}
return $result;
});
}
}
You can’t perform that action at this time.