-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a way to automate the instalation of drupal in a language other than english #704
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,46 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it a bit fragile to do it with string manipulations.
Why not doing this inside Robo?
Then, as Drupal is bootstrapped, we can simply use the API to achieve this. Then we can a drush cex
and a git commit
even.
Also
<?php
// Ensure this file is executed in the context of a Drupal bootstrap.
use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Entity\ConfigurableLanguage;
if (!drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL)) {
drush_log('This script must be run in the context of a fully bootstrapped Drupal site.', 'error');
exit(1);
}
// Define the language code of the new language to be installed.
$new_language_code = 'es'; // Spanish (change 'es' to the desired language code).
// Check if the language already exists.
$existing_language = \Drupal::languageManager()->getLanguage($new_language_code);
if ($existing_language) {
drush_log(dt('The language @lang_code already exists.', ['@lang_code' => $new_language_code]), 'warning');
return;
}
// Create and save the new language.
ConfigurableLanguage::create([
'id' => $new_language_code,
'label' => 'Spanish', // Change this to the appropriate language name.
'weight' => 0,
'locked' => LanguageInterface::LOCKED
])->save();
drush_log(dt('The language @lang_code has been added.', ['@lang_code' => $new_language_code]), 'success');
// Rebuild the cache.
drupal_flush_all_caches();
drush_log('Cache has been cleared.', 'success');
(AI, as-is)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it a bit fragile to do it with string manipulations.
Yep true. Maybe we can set this feature as experimental and use with caution, by default for English it does nothing as it exits before doing any string manipulation.
@AronNovak The reason for leaving this out of Robo is because this approach install all the content in the language of choice. Adding a new language and doing a config export will leave a lot of content created English.
Thanks. I think we should hold this PR, until we get enough real use cases for this (as currently we don't have any in Gizra AFAIK). I think for now whoever tries it could go with the manual work described in #688 (comment) |
#688