Edit online

The format-date() XPath Function Does Not Respect the Specified Locale

Problem

Formatting a date using another language code, as in this example:
title:before {
   content: oxy_xpath('format-date(current-date(), "[Mn] [Y]", "ru", (), ())');
}
results in an output like: [Language: en]september 2019, with the date being formatted in English.

Cause

The XPath expressions are evaluated using the Saxon HE processor. This processor does not support languages other than English.

Solution

As a solution, you can either switch to a more language-neutral format that avoids the months names:
title:before{
   content: oxy_xpath('format-date( current-date(), "[M] [Y]", "en", (), ())');
}
or you can use a more complex XPath expression like this:
title:before{
            
            content: oxy_xpath("let $cm:= format-date(current-date(), '[MNn]') \

return  concat( \

if ($cm= 'January') then  'JAN' else \

if ($cm= 'February') then  'FEB' else \

if ($cm= 'March') then  'MAR' else \

if ($cm= 'April') then  'APR' else \

if ($cm= 'May') then  'MAY' else \

if ($cm= 'June') then  'JUNE' else \

if ($cm= 'July') then  'JUL' else \

if ($cm= 'August') then  'AUG' else \

if ($cm= 'September') then  'SEPT' else \

if ($cm= 'October') then  'OCT' else \

if ($cm= 'November') then  'NOV' else  '' \

, \

' ', \

format-date(current-date(), '[Y0001]') \

) ");

}

Make sure the entire expression is rendered blue in the CSS editor. Replace the capitalized month names with the translation in the desired language.