MdnAgency / magento-cookie-consent

A simple cookie consent module for magento. It relies on new GTM consent functionality.
Open Software License 3.0
4 stars 4 forks source link

Fix the error where the translation file could not be found. #5

Closed hgati closed 2 months ago

hgati commented 2 months ago

Retrieve the locale code of the current site, read the corresponding translation JSON file within the module, and return its contents.

vberthet commented 2 months ago

Thanks for your proposition,

However i'm not sure that the way to go. The "Magento\Framework\View\Asset\Repository" as the necessary logic to handle assets translation and we shall not duplicate that in the module (See #3).

One improvement could be to catch the error if the translation is missing and fallback to "en_US" In CookieConsent.php

We can caught the exception when the file isn't found, log the error then fallback to en_US using :

$this->assetRepository->createAsset(self::TRANSLATION_FILE,["locale" => "en_US"])->getContent();
hgati commented 2 months ago

Frequent downtime occurs on the live server whenever a language pack is added, requiring recompilation of modules. Hence, it seems preferable to preload translation files within the module.

The languages from the Mageplaza language packs have been translated using ChatGPT 4o AI.

ko_KR de_DE sk_SK it_IT sv_SE nl_NL th_TH hu_HU mk_MK sw_KE lt_LT fil_PH is_IS bg_BG vi_VN uk_UA tr_TR es_ES ru_RU pt_PT pl_PL fa_IR lv_LV ja_JP id_ID hi_IN he_IL el_GR fi_FI et_EE da_DK cs_CZ hr_HR zh_CN ca_ES ar_SA gu_IN en_GB

041

042

043

044

vberthet commented 2 months ago

Thanks for your contribution. I've published a new version "v1.0.9" containing these changes.