// Sets the target and loads the current languages in your Drupal installation.
$code = 'pt';
$current_langcodes = \Drupal::languageManager()->getLanguages();
$current_langcodesList = array_keys($current_langcodes);
// Only creates the referred language if not exists.
if (!in_array($code, $current_langcodesList)){
$language = ConfigurableLanguage::createFromLangcode($code);
$language->save();
}
Last active
August 28, 2024 05:30
-
-
Save davidjguru/8bdeef7421a4cfde5df311b271d73d88 to your computer and use it in GitHub Desktop.
i18n: Loading a new Language in a Drupal installation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment