Problem/Motivation

Currently there are no drush commands for this module.

Proposed resolution

Add similar command to drush locale
'config_translation_po:export'
'config_translation_po:import'
'config_translation_po:import-all'

Remaining tasks

Currently added a patch for the import command "config_translation_po:import" as it was needed for a project I am working on.
All commands should be added.

CommentFileSizeAuthor
drush.patch4.28 KBalexandru.dumitru
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alexandru.dumitru created an issue. See original summary.

alexandru.dumitru’s picture

Issue summary: View changes
vighneshh’s picture

Assigned: Unassigned » vighneshh
alexandru.dumitru’s picture

Issue summary: View changes
dj1999’s picture

Status: Active » Needs review

rimi@aarhus.dk made their first commit to this issue’s fork.

dj1999’s picture

Assigned: vighneshh » Unassigned
Status: Needs review » Needs work

Needs working on coding standard.

rimi@aarhus.dk’s picture

Good point. I've cleaned up and defined coding standards.

I'm new to actually contributing to a Drupal module, so please let me know if anything must be done differently.

dj1999’s picture

Status: Needs work » Needs review

ressa’s picture

Status: Needs review » Needs work

This is great, both that there is a module which offers export and import of translated configuration, but also that a Drush command is close to being available.

The patch worked well for me (I created an MR to get a patch to test) the only thing I would suggest is perhaps add a few examples, like there is in the locale:export and locale:import commands?

EXPORT

$ drush locale:export -h
Exports to a gettext translation file.

See Drupal Core: \Drupal\locale\Form\ExportForm::submitForm

Examples:
 drush locale:export nl > nl.po                           Export the Dutch translations with all types.       
 drush locale:export nl --types=customized,not-customized Export the Dutch customized and not customized      
> nl.po                                                   translations.                                       
 drush locale:export --template > drupal.pot              Export the source strings only as template file for 
                                                          translation.                                        

Arguments:
 [langcode] The language code of the exported translations. 

IMPORT

$ drush locale:import -h
Imports to a gettext translation file.

Examples:
 drush locale-import nl drupal-8.4.2.nl.po     Import the Dutch drupal core translation.                           
 drush locale-import --type=customized nl      Import the Dutch drupal core translation. Treat imported strings as 
drupal-8.4.2.nl.po                             custom translations.                                                
 drush locale-import --override=none nl        Import the Dutch drupal core translation. Don't overwrite existing  
drupal-8.4.2.nl.po                             translations. Only append new translations.                         
 drush locale-import --override=not-customized Import the Dutch drupal core translation. Only override             
nl drupal-8.4.2.nl.po                          non-customized translations, customized translations are kept.      
 drush locale-import nl custom-translations.po Import customized Dutch translations and override any existing      
--type=customized --override=all               translation.                                                        

Arguments:
 langcode The language code of the imported translations.                                     
 file     Path and file name of the gettext file. Relative paths calculated from Drupal root. 

It doesn't have to be as many examples, but 2-3 maybe? Also, I think the odd path situation should be mentioned, where the two commands are "rooted" -- for export in the current folder, but import uses /web.

I added a new section "Deploying Drupal interface translations with Drush" on "Translating site interfaces" the other day, and a similar section for "Translating configuration" just now, since I could have really used a mention, when I visited that page the other day. Perhaps they can be used for inspiration?

dj1999’s picture

Status: Needs work » Needs review
ressa’s picture

In the end, I did not use the Config Translation PO module for configuration translation.

Instead, for elements such as block titles, and field names, I copied the relevant Twig template files to my theme, and added |trans to the labels. I updated the doc page with this tip, under Alternative solution: Make configuration elements translatable.