Skip to content
Snippets Groups Projects
Commit ced2fc60 authored by Marco Fernandes's avatar Marco Fernandes
Browse files

Issue #3319060: Core Gutenberg block titles are not translatable

parent 5c1d5090
No related branches found
No related tags found
No related merge requests found
......@@ -556,6 +556,7 @@ i18n:
js:
js/i18n.js: { }
js/drupal-gutenberg-translations.js: { }
js/core-blocks-translations.js: { }
dependencies:
- gutenberg/hooks
- gutenberg/polyfill
......
This diff is collapsed.
#!/usr/bin/env php
<?php
use Drupal\gutenberg\ScanDir;
$block_library_dir = realpath(dirname(__DIR__) . '/vendor/gutenberg/block-library');
$translations_file = __DIR__ . '/../js/core-blocks-translations.js';
require_once __DIR__ . '/utils.inc.php';
require_once get_drupal_root_directory() . '/autoload.php';
require_once __DIR__ . '/../src/ScanDir.php';
$json_files = ScanDir::scan([$block_library_dir], ['json'], TRUE);
$output = "/**\n";
foreach ($json_files as $file_name) {
$contents = file_get_contents("{$block_library_dir}/{$file_name}", TRUE);
$block = json_decode($contents);
$output .= " Drupal.t(\"{$block->title}\", {}, {context: \"block title\"});\n";
$output .= " Drupal.t(\"{$block->description}\", {}, {context: \"block description\"});\n";
}
$output .= "*/\n";
file_put_contents($translations_file, $output);
......@@ -15,25 +15,7 @@ Generates Gutenberg's info.yml library dependencies.
EOL;
require_once __DIR__ . '/_cli_include.inc.php';
/**
* Gets the Drupal root directory.
*
* @return string
* The root directory.
*/
function get_drupal_root_directory() {
$dirs = explode(DIRECTORY_SEPARATOR, __DIR__);
$root_dir = [];
foreach ($dirs as $key => $value) {
if ($value === 'modules') {
return implode(DIRECTORY_SEPARATOR, $root_dir);
}
$root_dir[] = $value;
}
throw new \RuntimeException('Could not find the Drupal root.');
}
require_once __DIR__ . '/utils.inc.php';
/**
* Gets the Drupal root directory.
......
<?php
/**
* Gets the Drupal root directory.
*
* @return string
* The root directory.
*/
function get_drupal_root_directory() {
$dirs = explode(DIRECTORY_SEPARATOR, __DIR__);
$root_dir = [];
foreach ($dirs as $key => $value) {
if ($value === 'modules') {
return implode(DIRECTORY_SEPARATOR, $root_dir);
}
$root_dir[] = $value;
}
throw new \RuntimeException('Could not find the Drupal root.');
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment