The language of the list of countries does not change in any form [OJS 3.3.0.5]

I noticed that in any forms where the list of countries is displayed, it is always displayed in English in any locales. In my case, this behavior is reproduced both on the local MAMP server for macOS and in Solaris in OJS 3.3.0.5.

Screenshot 2021-04-17 at 15.19.30

Screenshot 2021-04-17 at 15.19.05

Hi @crosfield, this is probably related to the languages available in your server configuration. Some suggestions are available in this thread on a similar issue: [OJS 3.2.0.3] Countries and Currencies locales - #15 by asmecher

Thanks for reply @NateWr!
I did some of the experiments described in [OJS 3.2.0.3] Countries and Currencies locales - #11 by asmecher and in GitHub - sokil/php-isocodes: PHP library providing ISO codes with localization: country (ISO 3166-1), subdivision (ISO 3166-2), language (ISO 639-3), currency (ISO 4217) and scripts (ISO 15924) on the local MAMP for MacOS. My primary language in OJS is Russian, and my second language is English. The output of locale -a contains “ru_RU” and many others languages, but output of the localetest.php is “Ukrainian” too. I tried different combinations of languages. For example, for

<?php

$locale = 'en_US';

putenv('LANGUAGE=' . $locale . '.UTF-8');
putenv('LC_ALL=' . $locale . '.UTF-8');
setlocale(LC_ALL, $locale . '.UTF-8');

require_once('lib/pkp/lib/vendor/autoload.php');
$isoCodes = new \Sokil\IsoCodes\IsoCodesFactory();
$languages = $isoCodes->getLanguages();

echo $languages->getByAlpha2('ru')->getLocalName() . "\n";

Russian is always displayed at any position of the “language switch”. Note that in the OJS interface, at any position of the language switch, a list of countries is always displayed in the second (English) language only.

The same problem exists on my working server on Solaris. But before requesting a technical team, I would like to understand how to solve this problem locally in MAMP for MacOS (I am the King and almost God here :slight_smile: ) Where can I find the cause of the problem?

P.S. I changed the program above by doing an experiment even with $locale = 'ru_RU';. The output is still Russian, but not Русский

@asmecher any ideas here?

Hi @crosfield,

Just to be sure I understand, your test PHP script (quoted above) demonstrates the same problem, correct? That it seems not to matter what value of $locale you use, the country list is always displayed in the server’s language?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher
Yes, I used a slightly modified example from [OJS 3.2.0.3] Countries and Currencies locales - #11 by asmecher. If I understand correctly, it should demonstrate that when you change the locale in OJS, the language of the message output also changes, but in my case the output language doesn’t change

Hi @crosfield,

The test script actually removes OJS from the picture entirely, and just depends on the third-party isocodes-php library that maintains country, locale, and currency lists.

If the test script doesn’t correctly translate the content, it usually means your system doesn’t have the requested locale enabled. The mechanism will be different depending on what OS you’re using and I’m afraid I don’t have a MacOS system available to work with. If you’re just looking to confirm on your local machine before working with your server, I’m not sure that’ll be a good pathway as the mechanisms for locale installation will be different on the two – you’ll go to the trouble of learning about locale settings on MacOS but it won’t apply on Solaris.

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks @asmecher! But is it possible not to bind to the locale installed in the user’s system, but to display a list of countries in the language of the current OJS locale?

Hi @crosfield,

I think that’s more related to the inner workings of the php-isocodes library than about OJS; I’m not sure why it’s necessary to have locale support on the OS in order for that library to translate to the requested language, but it does seem to be the case.

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks, @asmecher! I understand that it sounds strange, but I tested the site (OJS 3.3.0.5) on about 6 different OSs on several computers and in virtual machines (Windows XP RUS, Windows 7 RUS, Mac OS 10.15 with Eng & Rus System Locale, iOS 14 with Russian Springboard, Ubuntu 14 & 16 with Eng & Rus System Locale and in no system the list of countries on the site has never been in Russian. In English only. Always

Hi @crosfield,

I tried on my Ubuntu machine with the following test script:

<?php

$locale = 'ru_RU';

putenv('LANGUAGE=' . $locale . '.UTF-8');
putenv('LC_ALL=' . $locale . '.UTF-8');
setlocale(LC_ALL, $locale . '.UTF-8');

require_once('lib/pkp/lib/vendor/autoload.php');
$isoCodes = new \Sokil\IsoCodes\IsoCodesFactory();
$countries = $isoCodes->getCountries();

echo $countries->getByAlpha2('RU')->getLocalName() . "\n";

I successfully get the result:

Российская Федерация

Do you see the same?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher !
I’ve done a similar test before. But I did a test with your code too. Everywhere and always (including originally Russian-localized systems like Windows XP RU with Russian-localized version of Firefox) the output is “Russian Federation”, but not “Российская Федерация”. I think the problem lies in the fact that Apache used in MAMP and in Solaris for some reason does not correctly report the correct locales list to OJS. Is there any way to check using PHP (and not using ssh/command line) the locales available in an OS and then localize the problem?
Or is it possible to force OJS to show the Russian-language list of countries when OJS is switching to the Russian locale? Of course, this “trick” does not need to be included in the development, but this is how I will solve my problem for my server.
Thanks for your support!

P.S. By the way, I also noticed that if the dates in the backend in the section Website Settings > Date and Time Formats take into account localization, then on the frontend they are also always in English. And it is strange that in different parts of OJS localization is taken into account in different ways.
Screenshot 2021-04-26 at 01.10.40

Hi @crosfield,

We delegate the management of country, language, and currency lists to the third-party library GitHub - sokil/php-isocodes: PHP library providing ISO codes with localization: country (ISO 3166-1), subdivision (ISO 3166-2), language (ISO 639-3), currency (ISO 4217) and scripts (ISO 15924), and it appears that you’re running into an issue with that library’s seeming requirement that the locale be installed on the OS in order for translations to happen. We used to maintain our own country/language/locale lists, which was a lot of work and rapidly fell out-of-date, and I don’t think we’ll return to that. This leaves two options:

  • Either we change out that library for another, or
  • you could ask that library to reduce its dependency on system locale setting, or
  • you could investigate a little further why your system isn’t allowing the locale to be set.

Changing out the library is a lot of work, so I think the latter two options are the best.

Regards,
Alec Smecher
Public Knowledge Project Team

I did the same test as Alec on an Ubuntu server and visualized it as a result:

Russian Federation

After installing Russian language support (locale ru_RU.UTF-8 installed via dpkg-reconfigure locales) I got the result

Российская Федерация