Translate Country And Region Easy Store - Question | JoomShaper
SP Page Builder 6 is Here! Learn More →

Translate Country And Region Easy Store

T

Tilka

EasyStore 11 months ago

Good day, how can I translate the entire country and region selection dictionary, which users choose during checkout, into my native language? Currently, it is only available in English.

https://monosnap.com/file/uAuPyY550Q6ufOcPKdUomQVn9DMvYk

3
10 Answers
Mehtaz Afsana Borsha
Mehtaz Afsana Borsha
Accepted Answer
Support Agent 11 months ago #172671

Hello,

Thanks for contacting us.

You will find this in this file:

language/en-GB/com_easystore.ini

Please follow the documentation:

EasyStore Translation

Best regards

0
T
Tilka
Accepted Answer
11 months ago #172674

You misunderstood what I was talking about, I meant a dictionary of all countries and regions. There is no word in the file you specified, there is only a header for the Selector field. I already found it in the media/data folder.

0
Mehtaz Afsana Borsha
Mehtaz Afsana Borsha
Accepted Answer
Support Agent 11 months ago #172675

Sorry for misunderstanding and glad to know that you have already fixed the issue.

0
I
Imservan
Accepted Answer
11 months ago #174031

Hello Tilka, yes I would like that too. I am also looking for the file where I can, for example, translate the word “Germany” into German and so on. The same is with the federal states, for example the word “Bavaria” in Bavaria and so on. Have you already found the solution? Best regards Imservan

0
T
Tilka
Accepted Answer
11 months ago #174032

Hi,

it's here /media/com_easystore/data/countries.json

0
I
Imservan
Accepted Answer
11 months ago #174034

Thank you Tilka, for the quick support

0
R
RA
Accepted Answer
2 months ago #200580

Hello everybody - I am having the same issue, but simply changing the countries.json is not really a good solution, since the changes would be discarded when an easystore update is performed.

I would propose a different solution.

The logic for fetching the translation from countries.json are located here:

  • \JoomShaper\Component\EasyStore\Site\Controller\CheckoutController::getCountries
  • \JoomShaper\Component\EasyStore\Site\Controller\CheckoutController::getStates
  • \JoomShaper\Component\EasyStore\Site\Helper\EasyStoreHelper::getCountryStateFromJson

seem to be responsible for providing the counties and state strings. It would make sense to make a translation key lookup here, so that we could use the standard Joomla language/translation management system.

e.g. \JoomShaper\Component\EasyStore\Site\Controller\CheckoutController::getCountries could be changed this way.


use Joomla\CMS\Language\Text;
// ...
public function getCountries()
    {
        $countriesData = $this->loadCountriesData();

        $settingsModel     = new SettingsModel();
        $countryWithStates = $settingsModel->getCountriesWithStates();

        $codes = array_keys($countryWithStates);

        $countries = ArrayHelper::findByArray(function ($haystack, $item) {
            return ArrayHelper::find(function ($value) use ($item) {
                return $value->numeric_code == $item;
            }, $haystack);
        }, $countriesData, $codes);

        // original code
        // $countries = ArrayHelper::toOptions(function ($country) {
        //    return (object) [
        //        'label' => $country->name,
        //        'value' => $country->numeric_code,
        //    ];
        // }, $countries);

                // possibly new code 
        $countries = ArrayHelper::toOptions(function ($country) {
                    $languageString = 'COM_EASYSTORE_COUNTRY_' . $alpha_3;
                        $translation = Text::_($languageString);

                        // use translation if translation was found (e.g. when translation is not the same as languageString)
            return (object) [
                'label' => $translation == $languageString ?  $country->name : $translation,
                'value' => $country->numeric_code,
            ];
        }, $countries);

        $this->sendResponse($countries);
    }

This would be backwards compatible (since the fallback mechanism would use the country name from the JSON file) and it would be possible to override the String for exemple like this:

Germany:

COM_EASYSTORE_COUNTRY_DEU=Deutschland (for de translations) COM_EASYSTORE_COUNTRY_DEU=Germany (for en translations) ...

0
Mehtaz Afsana Borsha
Mehtaz Afsana Borsha
Accepted Answer
Support Agent 2 months ago #200597

Hi RA,

Thanks for sharing the solution. I hope other users are also get help from it.

-Regards.

0
R
RA
Accepted Answer
2 months ago #200615

Hi Mehtaz,

thanks for the quick response, this is actually more like a feature request (the normal user wont see that as any kind of help). With this approach you will be able to set the language string in the CMS and it would not break when an EasyStore Update occurrs.

It would make sense to forward this to the development team, so they can consider including this (or some variation of this) feature.

Normally I would post this kind of proposal on GitHub, but EasyStore is closed source (or at least not on GitHub or Private).

Thanks again

0
Mehtaz Afsana Borsha
Mehtaz Afsana Borsha
Accepted Answer
Support Agent 2 months ago #200742

Thanks for your suggestions. I will inform our DEV team about it.

0