I implemented a module with the directions presented in the following article:
However, I don't know how to translate the newly added country. For example, the one named as 'Abstract Country' at the above article. I tried with CSV files at the below locations, but this was not possible, at least on my Magento 2.4.6:
Hello @dandrikop
Identify the Language Pack:
Determine the language pack that you need to add the translations to. Language packs are typically stored in the app/i18n directory.
If you don’t already have a translation file, you will need to create one. The naming convention for translation files is xx_YY.csv, where xx is the language code and YY is the country code (e.g., en_US.csv for American English).
Add Translations to the CSV File:
Open the appropriate translation CSV file (or create one if it doesn’t exist) for the language you are targeting.
Add entries for your new country translations. Each entry in the CSV should follow the format: "Original text","Translated text".
For example, if you added a new country called "Atlantis" and you want to translate it into French, your fr_FR.csv might include: "Atlantis","Atlantide"
Place the CSV File in the Correct Location:
Ensure your CSV file is placed in the correct location within your Magento installation. Typically, this would be under app/i18n/Vendor/language_pack_code/.
app/i18n/Vendor/fr_FR/fr_FR.csv
Clear Cache:
bin/magento cache:clean bin/magento cache:flush
Deploy Static Content
bin/magento setup:static-content:deploy fr_FR
Custom Modules: If you are adding the country via a custom module, consider including the translation file within your module’s i18n directory.
Hope it helps !
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Thank You,
WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Location: 150 King St. W. Toronto, ON M5H 1J9
Hey,
$locale = new Zend_Locale('de_DE'); $countries = $locale->getTranslationList('Territory', $locale->getLanguage(), 2); echo $countries['DE'];
Thank You!