[OJS 3.2.0.3] Countries and Currencies locales

Hi,

List of countries and currencies dropdpwn list always show a list in the default locale even if switching to another language!
Please help to fix that by making language switching of countries and currencies.

Thanks!

HI @ahmedgad_it,

What language are you working with?

Regards,
Alec Smecher
Public Knowledge Project Team

Default language is Arabic and other languages are English, Francais

Hi @ahmedgad_it,

You might need to configure locales on your server; see https://github.com/sokil/php-isocodes#locale-configuration for details. (This is documentation for the 3rd-party we rely on for country lists etc.)

Regards,
Alec Smecher
Public Knowledge Project Team

Please be specific on where and how to configure that in the OJS source code.

Thanks!

Hi @ahmedgad_it,

Nothing needs to be done in the OJS source code; you need to enable and generate the locale information in your operating system. These are the instructions referencing the locale -a and locale-gen commands. The instructions may be different depending on your operating system.

Regards,
Alec Smecher
Public Knowledge Project Team

I’m using windows server. What are required configurations?

Hi @ahmedgad_it,

According to a php.net commenter, Windows might need an additional call in order to set the locale beyond what MacOSX/*NIX require.

To try this, edit lib/pkp/classes/i18n/PKPLocale.inc.php. Find the line:

setlocale(LC_ALL, $locale . '.' . LOCALE_ENCODING, $locale);

Add below it:

putenv("LC_ALL=$locale"); 

Please confirm whether that results in a translated country list – particularly in French, which I’ve tested with here.

Regards,
Alec Smecher
Public Knowledge Project Team

Please note all my .mo files are translated. The problem is with setting multiple languages in the dropdown list f “countries” and “currencies” to server multi-Lang users

I am still waiting help.

Hi @ahmedgad_it,

I would recommend trying a test script outside of OJS. Put a file named localetest.php in your OJS installation directory with the following contents:

<?php

$locale = 'ar_IQ';

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();

// Print the localized name of Ukrainian language in the locale defined above
echo $languages->getByAlpha2('uk')->getLocalName() . "\n";

Try running this. Is the name of the Ukrainian language it outputs localized to the ar_IQ language?

Regards,
Alec Smecher
Public Knowledge Project Team

No, it outputs “Ukrainian”.

Hi @ahmedgad_it,

That confirms that there’s something needing adjustment on your system, independent from OJS. Unfortunately I don’t have a Windows system to work with. You might have some luck opening an issue on the php-isocodes repository; that’s the library we rely on for the country list. Perhaps that developer can provide some guidance.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
Here is my question and the reply from php-isocodes:

Hi @ahmedgad_it,

I would suggest providing the test code above to illustrate the problem.

Regards,
Alec Smecher
Public Knowledge Project Team

Here is the reply:

This package does not manage locale of your application, it just use gettext to get translations.

You need to check that your application has correct locale, and that gettext use it.