{"id":57841,"date":"2023-07-30T16:24:00","date_gmt":"2023-07-30T10:54:00","guid":{"rendered":"https:\/\/tothenewco.pro\/blog\/?p=57841"},"modified":"2023-08-01T16:27:33","modified_gmt":"2023-08-01T10:57:33","slug":"custom-drush-command-to-import-all-po-files","status":"publish","type":"post","link":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/","title":{"rendered":"Custom Drush Command to import all .po files"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">The main purpose of this blog is to create a custom command to import all <strong>.po<\/strong> files. In one step\u00a0 <strong>Portable Object (.po)<\/strong> file is used for localization and content translation. <\/span><\/p>\n<p>Let&#8217;s start the creation of a custom drush command to import .po files:<\/p>\n<h2><strong>Step 1.\u00a0 Create Module<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">Create a <\/span><b>.info.yml<\/b><span style=\"font-weight: 400;\"> file<\/span><\/p>\n<pre class=\"p1\"><span class=\"s1\">name<\/span><span class=\"s2\">: <\/span><span class=\"s3\">Custom Drush<\/span>\r\n\r\n<span class=\"s1\">type<\/span><span class=\"s2\">: <\/span><span class=\"s3\">module<\/span>\r\n\r\n<span class=\"s1\">description<\/span><span class=\"s2\">: <\/span><span class=\"s3\">This module is used to create custom drush command to import *.po files<\/span>\r\n\r\n<span class=\"s3\">package<\/span><span class=\"s2\">: <\/span><span class=\"s4\">Custom<\/span>\r\n\r\n<span class=\"s3\">core_version_requirement<\/span><span class=\"s2\">: <\/span><span class=\"s4\">8.x || 9.x<\/span><\/pre>\n<h2 class=\"p1\"><span class=\"s1\"><b>Step 2: Create a service using services.yml<\/b><\/span><\/h2>\n<p class=\"p1\"><span class=\"s1\">Create a <strong>drush.services.yml<\/strong> file<\/span><\/p>\n<pre class=\"p3\"><span class=\"s1\">services<\/span><span class=\"s2\">:<\/span>\r\n\r\n<span class=\"s2\">\u00a0<\/span><span class=\"s1\">custom_drush.commands<\/span><span class=\"s2\">:<\/span>\r\n\r\n<span class=\"s2\">\u00a0\u00a0\u00a0<\/span><span class=\"s3\">class<\/span><span class=\"s2\">: <\/span><span class=\"s1\">\\Drupal\\<\/span><span class=\"s3\">custom_drush<\/span><span class=\"s1\">\\Commands\\AllDrushCommands<\/span>\r\n\r\n<span class=\"s2\">\u00a0\u00a0\u00a0<\/span><span class=\"s1\">tags<\/span><span class=\"s2\">:<\/span>\r\n\r\n<span class=\"s2\">\u00a0\u00a0\u00a0\u00a0\u00a0- { <\/span><span class=\"s3\">name<\/span><span class=\"s2\">: <\/span><span class=\"s1\">drush.command<\/span><span class=\"s2\"> }<\/span><\/pre>\n<h2><b>Step 3: Create a Drush Class<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Now let\u2019s extend the DrushCommands base class.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>Path :<\/strong> custom_drush\/src\/Commands\/AllDrushCommands.php<\/span><\/p>\n<pre class=\"p1\"><span class=\"s1\">&lt;?php<\/span>\r\n\r\n<span class=\"s2\">namespace<\/span> <span class=\"s1\">Drupal\\custom_drush\\Commands<\/span><span class=\"s3\">;<\/span>\r\n\r\n<span class=\"s2\">use<\/span><span class=\"s1\"> Drush\\Commands\\<\/span><span class=\"s4\">DrushCommands<\/span><span class=\"s1\">;<\/span>\r\n\r\n<span class=\"s1\">\/**<\/span>\r\n\r\n<span class=\"s1\">* A Drush commandfile.<\/span>\r\n\r\n<span class=\"s1\">*<\/span>\r\n\r\n<span class=\"s1\">* In addition to this file, you need a drush.services.yml<\/span>\r\n\r\n<span class=\"s1\">* in root of your module, and a composer.json file that provides the name<\/span>\r\n\r\n<span class=\"s1\">* of the services file to use.<\/span>\r\n\r\n<span class=\"s1\">*\/<\/span>\r\n\r\n<span class=\"s1\">class<\/span> <span class=\"s1\">AllDrushCommands<\/span> <span class=\"s1\">extends<\/span> <span class=\"s4\">DrushCommands<\/span><span class=\"s3\"> {<\/span>\r\n\r\n<span class=\"s1\">\/**<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0*<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0* @command custom_drush:ImportPoFiles<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0* @aliases import_po_files<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0* @usage custom_drush:cmgImportPo<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0* \u00a0 import all .po files.<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0*\/<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0<\/span><span class=\"s1\">public<\/span> <span class=\"s1\">function<\/span> <span class=\"s5\">ImportPoFiles<\/span><span class=\"s3\">() {<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0\u00a0<\/span><span class=\"s6\">$today<\/span><span class=\"s1\"> = <\/span><span class=\"s7\">date<\/span><span class=\"s1\">(<\/span><span class=\"s8\">\"Y-m-d\"<\/span><span class=\"s1\">);<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s6\">$langcodes<\/span><span class=\"s3\"> = \\<\/span><span class=\"s4\">Drupal<\/span><span class=\"s3\">::<\/span><span class=\"s1\">languageManager<\/span><span class=\"s3\">()-&gt;<\/span><span class=\"s1\">getLanguages<\/span><span class=\"s3\">();<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s1\">$langcodesList<\/span><span class=\"s3\"> = <\/span><span class=\"s7\">array_keys<\/span><span class=\"s3\">(<\/span><span class=\"s1\">$langcodes<\/span><span class=\"s3\">);<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s1\">\/\/ Get all .po files.<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0\u00a0<\/span><span class=\"s6\">$arrFiles<\/span><span class=\"s1\"> = <\/span><span class=\"s7\">glob<\/span><span class=\"s1\">(DRUPAL_ROOT .<\/span><span class=\"s8\">'\/*.po'<\/span><span class=\"s1\">);<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s2\">$this<\/span><span class=\"s3\">-&gt;<\/span><span class=\"s7\">output<\/span><span class=\"s3\">()-&gt;<\/span><span class=\"s7\">writeln<\/span><span class=\"s3\">(<\/span><span class=\"s1\">'Importing po files'<\/span><span class=\"s3\">);<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s6\">$starttimer<\/span><span class=\"s3\"> = <\/span><span class=\"s1\">'importingpofiles'<\/span><span class=\"s3\">;<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s4\">Timer<\/span><span class=\"s3\">::<\/span><span class=\"s7\">start<\/span><span class=\"s3\">(<\/span><span class=\"s1\">$starttimer<\/span><span class=\"s3\">);<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s9\">foreach<\/span><span class=\"s3\">(<\/span><span class=\"s1\">$arrFiles<\/span><span class=\"s3\"> as <\/span><span class=\"s1\">$file<\/span><span class=\"s3\">){<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span class=\"s6\">$file<\/span><span class=\"s1\"> = <\/span><span class=\"s7\">end<\/span><span class=\"s1\">(<\/span><span class=\"s7\">explode<\/span><span class=\"s1\">(<\/span><span class=\"s8\">'\/'<\/span><span class=\"s1\">,<\/span><span class=\"s6\">$file<\/span><span class=\"s1\">));<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span class=\"s1\">$file_langcode<\/span><span class=\"s3\"> = <\/span><span class=\"s7\">substr<\/span><span class=\"s3\">(<\/span><span class=\"s1\">$file<\/span><span class=\"s3\">,<\/span><span class=\"s10\">0<\/span><span class=\"s3\">,<\/span><span class=\"s7\">strlen<\/span><span class=\"s3\">(<\/span><span class=\"s1\">$file<\/span><span class=\"s3\">)-<\/span><span class=\"s10\">3<\/span><span class=\"s3\">);<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span class=\"s9\">if<\/span><span class=\"s3\"> (<\/span><span class=\"s7\">in_array<\/span><span class=\"s3\">(<\/span><span class=\"s1\">$file_langcode<\/span><span class=\"s3\">, <\/span><span class=\"s1\">$langcodesList<\/span><span class=\"s3\">)){<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span class=\"s1\">importPoTranslations<\/span><span class=\"s3\">([<\/span><span class=\"s6\">$file<\/span><span class=\"s3\">]);<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0\u00a0\u00a0\u00a0}<\/span>\r\n\r\n<span class=\"s1\">\u00a0\u00a0\u00a0}<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s1\">drush_backend_batch_process<\/span><span class=\"s3\">();<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s1\">\/\/ Time taken.<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s2\">$this<\/span><span class=\"s3\">-&gt;<\/span><span class=\"s7\">output<\/span><span class=\"s3\">()-&gt;<\/span><span class=\"s7\">writeln<\/span><span class=\"s3\">(<\/span><span class=\"s1\">'Time taken for importing .po files (seconds) = '<\/span><span class=\"s3\"> . (<\/span><span class=\"s4\">Timer<\/span><span class=\"s3\">::<\/span><span class=\"s7\">read<\/span><span class=\"s3\">(<\/span><span class=\"s6\">$starttimer<\/span><span class=\"s3\">) \/ <\/span><span class=\"s10\">1000<\/span><span class=\"s3\">));<\/span>\r\n\r\n<span class=\"s3\">\u00a0\u00a0\u00a0<\/span><span class=\"s1\">$timer_stats<\/span><span class=\"s3\"> = <\/span><span class=\"s4\">Timer<\/span><span class=\"s3\">::<\/span><span class=\"s7\">stop<\/span><span class=\"s3\">(<\/span><span class=\"s1\">$starttimer<\/span><span class=\"s3\">)<\/span>\r\n\r\n<span class=\"s1\">\u00a0}<\/span>\r\n\r\n<span class=\"s1\">}<\/span><\/pre>\n<h2 class=\"p4\"><b>Step 4: Create a method used in drush class<\/b><\/h2>\n<div>\n<pre>\/**\r\n\r\n* Function : importPoTranslations\r\n\r\n* Param : Array\r\n\r\n* Description : To import po files\r\n\r\n*\/\r\n\r\nfunction importPoTranslations( array $poFiles) {\r\n\r\n\\Drupal::moduleHandler()-&gt;loadInclude('locale', 'translation.inc');\r\n\r\n\\Drupal::moduleHandler()-&gt;loadInclude('locale', 'bulk.inc');\r\n\r\n$importer_options = array();\r\n\r\n$opt_langcode = '';\r\n\r\n$opt_set_customized = TRUE;\r\n\r\n$opt_replace_customized = TRUE;\r\n\r\n$opt_replace_not_customized = TRUE;\r\n\r\n\/\/ Import language files.\r\n\r\n$files = [];\r\n\r\n$langcodes_to_import = [];\r\n\r\nforeach ($poFiles as $file_path) {\r\n\r\n\/\/ Ensure we have the file intended for upload.\r\n\r\nif (file_exists($file_path)) {\r\n\r\n$opt_langcode = substr($file_path,0,strlen($file_path)-3);\r\n\r\n$importer_options = array_merge(_locale_translation_default_update_options(), [\r\n\r\n'langcode' =&gt; $opt_langcode,\r\n\r\n'customized' =&gt; $opt_set_customized ? LOCALE_CUSTOMIZED : LOCALE_NOT_CUSTOMIZED,\r\n\r\n'overwrite_options' =&gt; [\r\n\r\n'customized' =&gt; (int) $opt_replace_customized,\r\n\r\n'not_customized' =&gt; (int) $opt_replace_not_customized,\r\n\r\n],\r\n\r\n]);\r\n\r\n$file = locale_translate_file_create($file_path);\r\n\r\n$file = locale_translate_file_attach_properties($file, $importer_options);\r\n\r\nif ($file-&gt;langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) {\r\n\r\nif (!$opt_langcode) {\r\n\r\n\\Drupal::logger('update')\r\n\r\n-&gt;error(t('Can not autodetect language of file @file', ['@file' =&gt; $file_path]));\r\n\r\nreturn;\r\n\r\n}\r\n\r\n$file-&gt;langcode = $opt_langcode;\r\n\r\nif (empty($file-&gt;version) &amp;&amp; !empty($file-&gt;project) &amp;&amp; !empty($file-&gt;langcode)) {\r\n\r\n$sources = locale_translation_get_status();\r\n\r\n$source = $sources[$file-&gt;project][$file-&gt;langcode];\r\n\r\nif (isset($source-&gt;version)) {\r\n\r\n$file-&gt;version = $source-&gt;version;\r\n\r\n}\r\n\r\n}\r\n\r\n}\r\n\r\n$langcodes_to_import[$file-&gt;langcode] = $file-&gt;langcode;\r\n\r\n$files[] = $file;\r\n\r\n}\r\n\r\nelse {\r\n\r\n\\Drupal::logger('update')\r\n\r\n-&gt;error(t('File to import at @filepath not found.', ['@filepath' =&gt; $file_path]));\r\n\r\n}\r\n\r\n}\r\n\r\n$batch = locale_translate_batch_build($files, $importer_options);\r\n\r\nbatch_set($batch);\r\n\r\n\/\/ Create or update all configuration translations for this language.\r\n\r\nif ($batch = locale_config_batch_update_components($importer_options, $langcodes_to_import)) {\r\n\r\nbatch_set($batch);\r\n\r\n}\r\n\r\n}<\/pre>\n<div>\n<h2><b>Step 5: Clear the cache<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Now let\u2019s clear the cache to flush all caches with this command:<\/span><\/p>\n<pre><b>drush cr<\/b><\/pre>\n<p><span style=\"font-weight: 400;\">Now you can use the new command to import *.po files<\/span><\/p>\n<pre>drush import_po_files<\/pre>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">Finally, using this command on a multilingual website, you can import all .po files. No need to import the .po file one by one from the backend.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let us know in case of any queries, and please feel free to reach out via comments.<\/span><\/p>\n<\/div>\n<\/div>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>The main purpose of this blog is to create a custom command to import all .po files. In one step\u00a0 Portable Object (.po) file is used for localization and content translation. Let&#8217;s start the creation of a custom drush command to import .po files: Step 1.\u00a0 Create Module Create a .info.yml file name: Custom Drush [&hellip;]<\/p>\n","protected":false},"author":1599,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":24,"footnotes":""},"categories":[3602],"tags":[4884,5299],"class_list":["post-57841","post","type-post","status-publish","format-standard","hentry","category-drupal","tag-drupal-9","tag-multilingual"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"The main purpose of this blog is to create a custom command to import all .po files. In one step Portable Object (.po) file is used for localization and content translation. Let&#039;s start the creation of a custom drush command to import .po files: Step 1. Create Module Create a .info.yml file name: Custom Drush\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yogendra Pratap Singh\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Custom Drush Command to import all .po files | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"The main purpose of this blog is to create a custom command to import all .po files. In one step Portable Object (.po) file is used for localization and content translation. Let&#039;s start the creation of a custom drush command to import .po files: Step 1. Create Module Create a .info.yml file name: Custom Drush\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Custom Drush Command to import all .po files | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"The main purpose of this blog is to create a custom command to import all .po files. In one step Portable Object (.po) file is used for localization and content translation. Let&#039;s start the creation of a custom drush command to import .po files: Step 1. Create Module Create a .info.yml file name: Custom Drush\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-drush-command-to-import-all-po-files\\\/#article\",\"name\":\"Custom Drush Command to import all .po files | TO THE NEW Blog\",\"headline\":\"Custom Drush Command to import all .po files\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/yogendra-singh\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2023-07-30T16:24:00+05:30\",\"dateModified\":\"2023-08-01T16:27:33+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-drush-command-to-import-all-po-files\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-drush-command-to-import-all-po-files\\\/#webpage\"},\"articleSection\":\"Drupal, Drupal 9, Multilingual\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-drush-command-to-import-all-po-files\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/drupal\\\/#listItem\",\"name\":\"Drupal\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/drupal\\\/#listItem\",\"position\":2,\"name\":\"Drupal\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/drupal\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-drush-command-to-import-all-po-files\\\/#listItem\",\"name\":\"Custom Drush Command to import all .po files\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-drush-command-to-import-all-po-files\\\/#listItem\",\"position\":3,\"name\":\"Custom Drush Command to import all .po files\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/drupal\\\/#listItem\",\"name\":\"Drupal\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/yogendra-singh\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/yogendra-singh\\\/\",\"name\":\"Yogendra Pratap Singh\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-drush-command-to-import-all-po-files\\\/#authorImage\",\"url\":\"https:\\\/\\\/newersworld-sf-static.tothenew.net\\\/prod\\\/profilePicFolder\\\/e47c8cde-e05c-4e07-82fe-914d28db9261_1970-Yogendra-Pratap-Singh-PROFILEPICTURE.jpeg\",\"width\":96,\"height\":96,\"caption\":\"Yogendra Pratap Singh\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-drush-command-to-import-all-po-files\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-drush-command-to-import-all-po-files\\\/\",\"name\":\"Custom Drush Command to import all .po files | TO THE NEW Blog\",\"description\":\"The main purpose of this blog is to create a custom command to import all .po files. In one step Portable Object (.po) file is used for localization and content translation. Let's start the creation of a custom drush command to import .po files: Step 1. Create Module Create a .info.yml file name: Custom Drush\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-drush-command-to-import-all-po-files\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/yogendra-singh\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/yogendra-singh\\\/#author\"},\"datePublished\":\"2023-07-30T16:24:00+05:30\",\"dateModified\":\"2023-08-01T16:27:33+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Custom Drush Command to import all .po files | TO THE NEW Blog","description":"The main purpose of this blog is to create a custom command to import all .po files. In one step Portable Object (.po) file is used for localization and content translation. Let's start the creation of a custom drush command to import .po files: Step 1. Create Module Create a .info.yml file name: Custom Drush","canonical_url":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/#article","name":"Custom Drush Command to import all .po files | TO THE NEW Blog","headline":"Custom Drush Command to import all .po files","author":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/yogendra-singh\/#author"},"publisher":{"@id":"https:\/\/tothenewco.pro\/blog\/#organization"},"datePublished":"2023-07-30T16:24:00+05:30","dateModified":"2023-08-01T16:27:33+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/#webpage"},"isPartOf":{"@id":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/#webpage"},"articleSection":"Drupal, Drupal 9, Multilingual"},{"@type":"BreadcrumbList","@id":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog#listItem","position":1,"name":"Home","item":"https:\/\/tothenewco.pro\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/drupal\/#listItem","name":"Drupal"}},{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/drupal\/#listItem","position":2,"name":"Drupal","item":"https:\/\/tothenewco.pro\/blog\/category\/drupal\/","nextItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/#listItem","name":"Custom Drush Command to import all .po files"},"previousItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/#listItem","position":3,"name":"Custom Drush Command to import all .po files","previousItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/drupal\/#listItem","name":"Drupal"}}]},{"@type":"Organization","@id":"https:\/\/tothenewco.pro\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/tothenewco.pro\/blog\/"},{"@type":"Person","@id":"https:\/\/tothenewco.pro\/blog\/author\/yogendra-singh\/#author","url":"https:\/\/tothenewco.pro\/blog\/author\/yogendra-singh\/","name":"Yogendra Pratap Singh","image":{"@type":"ImageObject","@id":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/#authorImage","url":"https:\/\/newersworld-sf-static.tothenew.net\/prod\/profilePicFolder\/e47c8cde-e05c-4e07-82fe-914d28db9261_1970-Yogendra-Pratap-Singh-PROFILEPICTURE.jpeg","width":96,"height":96,"caption":"Yogendra Pratap Singh"}},{"@type":"WebPage","@id":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/#webpage","url":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/","name":"Custom Drush Command to import all .po files | TO THE NEW Blog","description":"The main purpose of this blog is to create a custom command to import all .po files. In one step Portable Object (.po) file is used for localization and content translation. Let's start the creation of a custom drush command to import .po files: Step 1. Create Module Create a .info.yml file name: Custom Drush","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/tothenewco.pro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/#breadcrumblist"},"author":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/yogendra-singh\/#author"},"creator":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/yogendra-singh\/#author"},"datePublished":"2023-07-30T16:24:00+05:30","dateModified":"2023-08-01T16:27:33+05:30"},{"@type":"WebSite","@id":"https:\/\/tothenewco.pro\/blog\/#website","url":"https:\/\/tothenewco.pro\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/tothenewco.pro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Custom Drush Command to import all .po files | TO THE NEW Blog","og:description":"The main purpose of this blog is to create a custom command to import all .po files. In one step Portable Object (.po) file is used for localization and content translation. Let's start the creation of a custom drush command to import .po files: Step 1. Create Module Create a .info.yml file name: Custom Drush","og:url":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/","og:image":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Custom Drush Command to import all .po files | TO THE NEW Blog","twitter:description":"The main purpose of this blog is to create a custom command to import all .po files. In one step Portable Object (.po) file is used for localization and content translation. Let's start the creation of a custom drush command to import .po files: Step 1. Create Module Create a .info.yml file name: Custom Drush","twitter:image":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"57841","title":null,"description":null,"keywords":[],"keyphrases":{"focus":[],"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":{"id":"#aioseo-article-65e0652965049","slug":"article","graphName":"Article","label":"Article","properties":{"type":"BlogPosting","name":"#post_title","headline":"#post_title","description":"#post_excerpt","image":"","keywords":"","author":{"name":"#author_name","url":"#author_url"},"dates":{"include":true,"datePublished":"","dateModified":""}}},"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":"{\"article\":{\"articleType\":\"BlogPosting\"},\"course\":{\"name\":\"\",\"description\":\"\",\"provider\":\"\"},\"faq\":{\"pages\":[]},\"product\":{\"reviews\":[]},\"recipe\":{\"ingredients\":[],\"instructions\":[],\"keywords\":[]},\"software\":{\"reviews\":[],\"operatingSystems\":[]},\"webPage\":{\"webPageType\":\"WebPage\"}}","pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"limit_modified_date":false,"created":"2023-08-01 07:13:23","updated":"2024-02-29 11:06:17","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/tothenewco.pro\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/tothenewco.pro\/blog\/category\/drupal\/\" title=\"Drupal\">Drupal<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tCustom Drush Command to import all .po files\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/tothenewco.pro\/blog"},{"label":"Drupal","link":"https:\/\/tothenewco.pro\/blog\/category\/drupal\/"},{"label":"Custom Drush Command to import all .po files","link":"https:\/\/tothenewco.pro\/blog\/custom-drush-command-to-import-all-po-files\/"}],"_links":{"self":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/57841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/users\/1599"}],"replies":[{"embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/comments?post=57841"}],"version-history":[{"count":4,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/57841\/revisions"}],"predecessor-version":[{"id":57878,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/57841\/revisions\/57878"}],"wp:attachment":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/media?parent=57841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/categories?post=57841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/tags?post=57841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}