{"id":445,"date":"2021-07-12T17:48:19","date_gmt":"2021-07-12T14:48:19","guid":{"rendered":"http:\/\/wp.plumserver.com\/learn\/?p=445"},"modified":"2024-05-09T16:16:52","modified_gmt":"2024-05-09T13:16:52","slug":"translating-magento-2-extension-using-theme-translation-files-2","status":"publish","type":"post","link":"https:\/\/plumrocket.com\/learn\/magento-theme-translation","title":{"rendered":"How to Translate Magento 2 Extension Using Theme Translation Files"},"content":{"rendered":"\n<p>In this article, you will learn how to perform Magento 2 theme file translation. <\/p>\n\n\n\n<p>Usually, the translations are stored in the .csv files on your server. However, if, for some reason, there is no CSV translation file translated for your language, you will need to create the .csv file from scratch. To create the CSV translation file, please follow the steps below.<\/p>\n\n\n\n<div class=\"wp-block-group pr-notice pr-notice-warning\"><div class=\"wp-block-group__inner-container\">\n<p class=\"pr-notice-title\">Important Information:<\/p>\n\n\n\n<p>Make sure to disable Magento 2 cache before proceeding with .csv file translation.<\/p>\n<\/div><\/div>\n\n\n\n<h2>Step 1. Create the required file for translation<\/h2>\n\n\n\n<p>First, in your Magento 2 admin panel, you need to find the .csv file and copy it to create the required file for the translation. Please, check the example below.<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-bash\">app\/design\/frontend\/THEME_VENDOR\/theme_name\/i18n\/en_US.csv<\/code><\/pre><\/div>\n\n\n\n<p>Name the file to include the target language code. This is an example file with a German translation:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-bash\">app\/design\/frontend\/THEME_VENDOR\/theme_name\/i18n\/de_De.csv<\/code><\/pre><\/div>\n\n\n\n<h2>Step 2. Translate the phrases according to the requirements<\/h2>\n\n\n\n<p>While translating, make sure all the strings in your .csv file start and end with double quotes, and are separated with comma [,], not semi-colon [;] or any other mark.<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">\"Add to Cart\", \"Translated Text\"<\/code><\/pre><\/div>\n\n\n\n<p>You can change the default theme strings according to the requirements of your website, for example:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">\"My Cart\",\"My Basket\"\n\"My Account\",\"Your Account\"<\/code><\/pre><\/div>\n\n\n\n<p>All the lines are case-sensitive, you should copy the phrase exactly as it is in the &#8220;en_US&#8221; version. In the source &#8220;en_US&#8221; version the text looks like this:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">\"%s Item(s)\",\"%s Item(s)\"<\/code><\/pre><\/div>\n\n\n\n<p>Whereas the translated text should look like this:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">\"%s Items\",\"%s Product(s)\"<\/code><\/pre><\/div>\n\n\n\n<p>If you need to set off a word or phrase by quotation marks, put two double quotation marks for such a string.<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">\"String\",\"Translated word\"<\/code><\/pre><\/div>\n\n\n\n<p>You can also use HTML coding to alter your text. Check an example:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">\"Warning!\",\"&lt;strong style=\"color:red\">Attention!&lt;\/strong>\"<\/code><\/pre><\/div>\n\n\n\n<h2>Step 3. Save the CSV file in UTF-8 encoding<\/h2>\n\n\n\n<p>Make sure your text editor saves .csv file in UTF-8 encoding, as it supports different alphabets. If you edit the file using Excel, convert it into UTF-8 encoding once you finish editing.<\/p>\n\n\n\n<h3>How to translate the same element differently for different pages<\/h3>\n\n\n\n<p>While performing translation in this file &#8211; any word or phrase will be translated for the entire theme. If you need to translate the same element in different ways for different pages, you can use this example:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-json\">\"Mage_Catalog:Add to Cart\",\"Add to Basket\"\n\"Mage_Checkout:Add to Cart\",\"Add to my shopping cart\"<\/code><\/pre><\/div>\n\n\n\n<p>To read more information about Magento 2 translations, please <a href=\"https:\/\/devdocs.magento.com\/guides\/v2.3\/frontend-dev-guide\/translations\/xlate.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">click here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><!-- wp:paragraph --><\/p>\n<p>In this article you will learn how to perform Magento 2 theme files translation. <\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Usually, the translations are being stored in the .csv files on your server. However, if for some reason there&#8217;s no CSV translation file translated for your language &#8211; you will need to create the .csv file from scratch. To create the CSV translation file &#8211; please follow the steps below.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[123],"tags":[139,137],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Translate Magento 2 Extension Using Theme Translation Files - Magento Tutorials for Beginners &amp; Professionals<\/title>\n<meta name=\"description\" content=\"Learn how to translate the Magento 2 extension using theme files. First, you need to create the required file using our example.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/plumrocket.com\/learn\/magento-theme-translation\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Translate Magento 2 Extension Using Theme Translation Files - Magento Tutorials for Beginners &amp; Professionals\" \/>\n<meta property=\"og:description\" content=\"Learn how to translate the Magento 2 extension using theme files. First, you need to create the required file using our example.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/plumrocket.com\/learn\/magento-theme-translation\" \/>\n<meta property=\"og:site_name\" content=\"Magento Tutorials for Beginners &amp; Professionals\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-12T14:48:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-09T13:16:52+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts\/445"}],"collection":[{"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/comments?post=445"}],"version-history":[{"count":12,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts\/445\/revisions"}],"predecessor-version":[{"id":1284,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts\/445\/revisions\/1284"}],"wp:attachment":[{"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/media?parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/categories?post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/tags?post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}