Search code examples
phpzend-frameworktranslation

PHP Zend 1 Date translations not translating correctly for Finnish


I'm working on a fairly old project, built on the Zend 1 framework.

There's an issue with translation, specifically Finnish.

To test, I'm running the following code:

(new Zend_Date(time(), false, new Zend_Locale($locale)))->toString(Zend_Date::DATE_FULL);

Assigning $locale the following values give the following results, respectively:

  • English: 'en' results in 'Monday, August 21, 2023'
  • Finnish: 'fi' results in 'cccc 21. elokuuta 2023'
  • Danish: 'da' results in 'mandag den 21. august 2023'
  • Norwegian: 'nb' results in 'mandag 21. august 2023'

The correct translation for the Finnish string is 'maanantai 21. elokuuta 2023', but for some reason it's outputting 'cccc' instead of the correct string. Does anyone have an idea of what might be wrong?


Solution

  • The Zend Framework has been long-since abandoned. Your exact question appears in their archived GitHub issues from nearly a decade ago. The answer: it's old, there are numerous issues, and nobody is going to update the translation & internationalization files at this point.

    Luckily, that line of code can easily be updated to use the INTL extension (which wraps ICU's C library) and will deliver the correct output via the IntlDateFormatter class:

    echo (new IntlDateFormatter($locale, IntlDateFormatter::FULL, IntlDateFormatter::NONE))->format(time());
    

    Live example on 3v4l.