I do not know if I am missing something...
In an older (quite old) 8.x-1.x dev version there was a drush option "--language" to not only collect the strings to be translated but to also include existing translations.
I did not found anything in the issues according this (or a similiar) option.
Comparing my old version to current dev I found some small differences in potx.drush.inc.
I do not really understand the internals but I just added the option "--language" and changed the call to _potx_build_files():
@@ -22,6 +22,7 @@ function potx_drush_command() {
'files' => 'Comma delimited list of files to extract translatable strings from.',
'folder' => 'Folder to begin translation extraction in. When no other option is set this defaults to current directory.',
'api' => 'Drupal core version to use for extraction settings.',
+ 'language' => 'language to include in the po file',
],
'examples' => [
'potx single' => 'Extract translatable strings from applicable files in current directory and write to single output file',
@@ -75,6 +76,7 @@ function potx_drush_extract($mode = NULL) {
$files_option = drush_get_option('files');
$folder_option = drush_get_option('folder');
$api_option = drush_get_option('api');
+ $language_option = drush_get_option('language');
if (empty($api_option) || !in_array($api_option, [5, 6, 7, 8])) {
$api_option = POTX_API_CURRENT;
}
@@ -105,7 +107,16 @@ function potx_drush_extract($mode = NULL) {
potx_finish_processing('_potx_save_string', $api_option);
- _potx_build_files(POTX_STRING_RUNTIME, $build_mode);
+ _potx_build_files(
+ POTX_STRING_RUNTIME,
+ $build_mode,
+ 'general',
+ '_potx_save_string',
+ '_potx_save_version',
+ '_potx_get_header',
+ $language_option,
+ $language_option
+ );
_potx_build_files(POTX_STRING_INSTALLER, POTX_BUILD_SINGLE, 'installer');
_potx_write_files();
Worked like a charm :)
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | reroll_diff_3-7.txt | 570 bytes | wilfred waltman |
| #7 | 3075494-7.patch | 2.56 KB | wilfred waltman |
| #4 | potx-drush_language-3075494-4.patch | 6.66 KB | floydm |
| #4 | interdiff-3-4.txt | 4.81 KB | floydm |
| #3 | interdiff-2-3.txt | 2.56 KB | floydm |
Comments
Comment #2
gngn commentedPatch attached.
Comment #3
floydm commentedThanks for this! This adds Drush 9 support
Comment #4
floydm commentedI'm not sure how conflicts between patches on different tickets are supposed to be handled, but I need to extract strings from the theme too. This patch works out the conflict between the patch from comment #3 here with the patch on comment #12 on
https://www.drupal.org/project/potx/issues/2641334#comment-13109174
Comment #5
super_romeo commentedPatch Failed to Apply.
Comment #6
gábor hojtsy@floydm: would be great to either get this one committed first or that one committed first. We'll not commit them both from one issue. That way the credits, discussion history, etc. is intact and referenced from the commit.
Comment #7
wilfred waltman commentedAs far as I can tell the first part of the patch from #3 is already implemented in 8.x-1.0.0-alpha1 version.
So here's a reroll of that patch.
Comment #8
gábor hojtsyHm, there was a bit of a cross-work here. Language and translation support in drush was already landed in #2175955: Support language dependent content and translations export in Drush command and #3169697: New language and translations options were not added to Drush 9/10 integration.
Closing this down as fixed to grant issue credits for all who worked on this variant. I believe this feature is fully implemented in those issues.