By editor, 30 September, 2021 Translation API - PHP Twig JavaScript Tags Drupal 8 Drupal 9 Translation JavaScript Twig PHP PHP Class using StringTranslationTrait StringTranslationTrait allow to get t() and formatPlural() methods Example: use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; class MyClass {
By editor, 23 December, 2015 Delete a source string and the target translations in Drupal 8 Tags Drupal 8 Code Translation As you haven't a Delete button on interface translation page, you can't do that from the translation interface. But you can do in a small custom module. Example : Delete string ID 346, 'Home' $lid = 346;
By editor, 1 December, 2015 Get all languas of the site in Drupal 8 Tags Drupal 8 Code Translation To get languages in English: $site_languages = \Drupal::languageManager()->getLanguages(); To get languages in native language: $site_languages = \Drupal::languageManager()->getNativeLanguages();
By editor, 28 November, 2015 Create and translate a multilingual nodes programmatically. Tags Drupal 8 Code Translation Node Programmatically create and translate nodes.
By editor, 28 November, 2015 Translate a node programmatically Tags Drupal 8 Code Translation Node Exemples: $translation = $entity->getTranslation('de');
By editor, 6 November, 2015 How to get the current language in Drupal 8 Tags Drupal 8 Code Translation User Drupal 8 //To get the lanuage code: $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); //To get the language name: $language = \Drupal::languageManager()->getCurrentLanguage()->getName();