{"id":507,"date":"2021-07-21T13:29:43","date_gmt":"2021-07-21T10:29:43","guid":{"rendered":"http:\/\/wp.plumserver.com\/learn\/?p=507"},"modified":"2022-10-05T19:04:06","modified_gmt":"2022-10-05T16:04:06","slug":"translating-magento-2-extension-using-csv-files","status":"publish","type":"post","link":"https:\/\/plumrocket.com\/learn\/magento-extension-translation","title":{"rendered":"How to Translate Magento 2 Extensions Using CSV Files"},"content":{"rendered":"\n<p>In this article, you will learn how to translate your Magento 2 extensions. <\/p>\n\n\n\n<p>Generally, Magento uses a translation dictionary so that you can localize your store. This dictionary is a .csv file with two columns: the original text in the source (en_US) locale and the translation of that text in a target locale. Therefore, you need to perform Magento 2 CSV files translation by adding and applying the translation phrases.<\/p>\n\n\n\n<h2>Step 1. Create a CSV file &amp; copy phrases for translation<\/h2>\n\n\n\n<p>Create the <code>your_lanuage_code.csv<\/code> file in the <code>app\/code\/Plumrocket\/&lt;Module_Name&gt;\/i18n<\/code> directory:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div class=\"prism-title\">Example for German<\/div><pre><code class=\"language-markup\">app\/code\/Plumrocket\/&lt;Module_Name>\/i18n\/de_DE.csv <\/code><\/pre><\/div>\n\n\n\n<p>Copy the phrases you need to translate from the following file:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">app\/code\/Plumrocket\/&lt;Module_Name>\/i18n\/en_US.csv <\/code><\/pre><\/div>\n\n\n\n<p>If the file is missing, you need to add a set of phrases for translation manually into the <code>app\/code\/Plumrocket\/&lt;Module_Name&gt;\/i18n\/de_DE.csv<\/code> file.<\/p>\n\n\n\n<h2>Step 2. Translate phrases in each string<\/h2>\n\n\n\n<p>Open this <code>.csv<\/code> file using any text editor (e.g. Notepad++) and translate the phrase in each string. All the phrases in your .csv file should be written in double quotes and should be separated by commas [,]<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div class=\"prism-title\">Translation example into German<\/div><pre><code class=\"language-json\">\"Add to Cart\", \"In den Warenkorb\"<\/code><\/pre><\/div>\n\n\n\n<h2>Step 3. Remove the js-translation.json file<\/h2>\n\n\n\n<p>Now you have to apply the translation you have entered in the <code>.csv<\/code> file.&nbsp;Please, proceed with the following steps:<\/p>\n\n\n\n<p class=\"pr-notice pr-notice-info\">In Developer mode, you can disable Magento Cache to display changes instantly (does not apply to JS translation). <\/p>\n\n\n\n<p>In the terminal, switch to your Magento 2 root directory using the following command:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-bash\">cd \/FULL_PATH_TO_YOUR_MAGENTO2<\/code><\/pre><\/div>\n\n\n\n<p>Remove the following file:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-bash\">pub\/static\/frontend\/&lt;vendor>\/&lt;theme_name>\/&lt;locale_code>\/js-translation.json<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div class=\"prism-title\">Example file name for Luma theme in German <\/div><pre><code class=\"language-\">pub\/static\/frontend\/Magento\/luma\/de_DE\/js-translation.json<\/code><\/pre><\/div>\n\n\n\n<h2>Step 4. Deploy the CSV file with translation<\/h2>\n\n\n\n<p>Next, run the following command to deploy the translated file (please skip this step if Magento is in developer mode):<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-\">php bin\/magento setup:static-content:deploy --theme &lt;vendor>\/&lt;theme_name> &lt;locale_code><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div class=\"prism-title\">Command example for Luma theme in German <\/div><pre><code class=\"language-\">php bin\/magento setup:static-content:deploy --theme Magento\/luma de_DE<\/code><\/pre><\/div>\n\n\n\n<h2>Step 5. Flush Magento cache<\/h2>\n\n\n\n<p>Flush Magento Cache using the following command:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-bash\">php bin\/magento cache:flush<\/code><\/pre><\/div>\n\n\n\n<p>Please make sure to refresh the page after you have applied your translation. If necessary, please check <a href=\"https:\/\/devdocs.magento.com\/guides\/v2.3\/frontend-dev-guide\/translations\/xlate.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Magento DevDocs<\/a> for more information about Magento 2 translation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><!-- wp:paragraph --><\/p>\n<p>Generally, Magento uses a translation dictionary so that you can localize your store. This dictionary is a .csv file with two columns: the original text in the source (en_US) locale and the translation of that text in a target locale. Therefore, you need to perform Magento 2 CSV files translation by adding and applying the translation phrases.<\/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":[138,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 Extensions Using CSV Files - Magento Tutorials for Beginners &amp; Professionals<\/title>\n<meta name=\"description\" content=\"Learn how to add translational phrases to a CSV file and apply them correctly in order to translate Magento 2 extensions.\" \/>\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-extension-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 Extensions Using CSV Files - Magento Tutorials for Beginners &amp; Professionals\" \/>\n<meta property=\"og:description\" content=\"Learn how to add translational phrases to a CSV file and apply them correctly in order to translate Magento 2 extensions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/plumrocket.com\/learn\/magento-extension-translation\" \/>\n<meta property=\"og:site_name\" content=\"Magento Tutorials for Beginners &amp; Professionals\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-21T10:29:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-05T16:04:06+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\/507"}],"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=507"}],"version-history":[{"count":29,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts\/507\/revisions"}],"predecessor-version":[{"id":1244,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts\/507\/revisions\/1244"}],"wp:attachment":[{"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/media?parent=507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/categories?post=507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/tags?post=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}