8 – Symbols for certain locales missing in multilingual sites when using the number formatter moule to format integers to ordinal numbers


I was looking for a module that converts integers entered in a field into ordinal numbers, For eg 22 to 22nd and 33 to 33rd.

I ran into the https://www.drupal.org/project/number_formatter and it works

The module works really well for English (en) converting 1 to 1st, 2 to 2nd, and so on.

However, for other languages like Arabic with locale ‘ar’ it is not converting accurately. The symbol seems to be missing and instead, we get a ‘.’. The same happens for ru as well. “

I debugged the module and I found that it was using the core PHP class NumberFormatter.

use NumberFormatter as IntlNumberFormatter;

$language = $this->languageManager->getCurrentLanguage()->getId();
$numberFormatter = new IntlNumberFormatter($language, $this->settings('style'));

Dumping the $numberFormatter led me to the following output.

^ NumberFormatter {#2773 ▼
  locale: "ar"
  pattern: """
    %digits-ordinal:


    0: =#,##0=.;


    -x: −>%digits-ordinal>;


    """
  attributes: {▶}
  text_attributes: {▶}
  symbols: {▶}
  error_code: 16
  error_message: "Error getting symbol value: U_UNSUPPORTED_ERROR"
}

I tested this code separately and found that the problem exists outside the module and is likely a core PHP bug. Is there something additional we need to do get this fixed?