{"id":1106,"date":"2020-07-08T10:16:52","date_gmt":"2020-07-08T10:16:52","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/07\/08\/translate-using-xml-in-magento-2\/"},"modified":"2025-07-17T10:39:07","modified_gmt":"2025-07-17T05:09:07","slug":"translate-using-xml-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/translate-using-xml-in-magento-2\/","title":{"rendered":"How to Translate Using XML in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">It is a general observation that customers prefer viewing online content, especially when it comes to E-commerce, in their native languages. And why not! Online visitors are very impatient. So offer them what they love, what is easily readable, and content that they can grasp quickly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, as\u00a0Magento 2\u00a0is a worldwide popular platform used by online businesses in multiple languages, translating the store\u2019s content is inevitable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Translating the store\u2019s content can lead to more sales because international customers can better understand the product details and can relate to your business on a higher level.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, if you have tried translating using CSV but failed, you probably missed a step. And that\u2019s why you need to follow this method to&nbsp;translate using XML in Magento 2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to translate using XML in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As a Magento developer, it is a common practice for translating words through&nbsp;<strong>.csv<\/strong>&nbsp;file located at<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>app\/code\/Vendor\/Extension\/i18n<\/strong><\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Just add&nbsp;<strong>i18n folder<\/strong>&nbsp;in custom extension and in that, create .csv file with a translation of words like \u201cClick Here\u201d, \u201cKlik hier\u201d.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Observe that, the name of CSV starts with language name like en_US.csv, ar_SA.csv etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Despite following these steps, if some words are not translating in your store, then probably you might have missed, as shown below:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to translate \u201ccity\u201d field in dutch language from English and you\u2019ve passed that field like below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;item name=\"label\" xsi_type=\"string\" >City&lt;\/item><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In CSV file you\u2019ve done every step perfectly like \u201ccity\u201d, \u201cstad\u201d but word city is not translating then once check your XML file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The correct method, which you have forgotten is:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;item name=\"label\" xsi_type=\"string\" translate=\"true\">City&lt;\/item><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Adding&nbsp;<code>translate=\u201dtrue\u201d<\/code><strong>&nbsp;<\/strong>is what you had skipped but not after following this post!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And yeah\u2026let me remind you to use <code>echo __(\u2018your word\u2019)<\/code> in phtml file too  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019re looking for the method to&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/translate-js-error-message-or-text-in-magento-2\/\">translate JS error message or text In Magento 2<\/a>&nbsp;then visit our blog.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are Switching to an Arabic store or changing the store view to Arabic changes and want to <a href=\"https:\/\/meetanshi.com\/blog\/change-price-decimal-separator-for-arabic-store-in-magento-2\/\" data-type=\"link\" data-id=\"https:\/\/meetanshi.com\/blog\/change-price-decimal-separator-for-arabic-store-in-magento-2\/\">Change Price Decimal Separator<\/a> for Arabic Store in Magento 2 Read our blog. Do share the tutorial with fellow Magento developers via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is a general observation that customers prefer viewing online content, especially when it comes to E-commerce, in their native languages. And why not! Online&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1106","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1106"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1106\/revisions"}],"predecessor-version":[{"id":16819,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1106\/revisions\/16819"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}