pikim / grav-plugin-events

This plugin provides Calendar Events for Grav CMS
MIT License
13 stars 11 forks source link

Translation of German umlauts isn't displayed properly #5

Closed pikim closed 4 years ago

pikim commented 4 years ago

When a month name contains German umlauts, the translation won't be displayed properly. E.g. März: only the first two letters are shown instead of the first 3. When a month name doesn't contain umlauts it works well, see: grafik

git-rebug commented 4 years ago

I suppose the problem occurs when umlauts and substr(...) meet, so that possibly a single special character takes a number of characters > 1. See also https://www.php.net/manual/en/function.mb-substr.php. The relevant code positions would be the following:

https://github.com/pikim/grav-plugin-events/blob/46d1514fa869f9119028f207d9ff763e0178f3d6/twig/DateTranslationExtension.php#L106

https://github.com/pikim/grav-plugin-events/blob/46d1514fa869f9119028f207d9ff763e0178f3d6/twig/DateTranslationExtension.php#L114

I will probably be able to do some debugging in about a week.

pikim commented 4 years ago

It's an issue with substr, exactly the way you described it. I replaced substr with mb_substr and passed "UTF-8" as fourth parameter and now it works. It will be contained in the next release.