Skip to content

Commit

Permalink
tweak(TB Twig) backport transliterate fix
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmhh committed Sep 2, 2024
1 parent ac720be commit 3814775
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions tine20/Tinebase/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,7 @@ protected function _addTwigFunctions()
return str_replace(' ', '', (string)$str);
}));
$this->_twigEnvironment->addFilter(new Twig_SimpleFilter('transliterate', function($str) {
return Tinebase_Helper::replaceSpecialChars($str, false);
// much better would be iconv or transliterator
// iconv('UTF-8', 'ASCII//TRANSLIT', iconv(mb_detect_encoding($str), 'UTF-8//IGNORE', $str));
// this iconv works very well on the glibc implementation, sadly docker php versions may come with
// a different iconv implementation: Interactive shell
// php > echo ICONV_IMPL;
// unknown
// => that implementation transliterates ö to "o instead of oe
// transliterator_transliterate('de-ASCII', $str); does not transliterate € sign, also I have trouble with
// that 'de' in there... probably the transliterator would be the best option, but we would need to find
// the right way to use it, feel free to improve
return iconv('UTF-8', 'ASCII//TRANSLIT', transliterator_transliterate('de-ASCII', $str));
}));

$this->_twigEnvironment->addFilter(new Twig_SimpleFilter('preg_replace', function($subject, $pattern, $replacement, int $limit=-1, int $count=null) {
Expand Down

0 comments on commit 3814775

Please sign in to comment.