Skip to main content
Home
Techies Briefcase
~ by Hari Venu

Main navigation

  • Home
  • Tools
    • Placeholder Image
    • JSON Diff
    • QR Code Generator
    • Random String Generator
    • HTML to PDF Generator
  • About me
  • Photos
  • Search

Breadcrumb

  1. Home
  2. Drupal 9 Get The Current Language Programmatically

Drupal 9 get the current language programmatically

By hari, 31 August, 2023

To retrieve the current language in use on a Drupal 8 site, you can use the following code:

The 2-character ISO code (639-1) for the language will be returned. So for French, it will be "fr" and for English "en" for example.

To retrieve the name of the language rather than the code, you can use this:

Note also that to retrieve the language in use for the content, you must use the constant LanguageInterface::TYPE_CONTENT :

Tags

  • Drupal
  • Multilingual
 

Topics

  • Form API
  • Windows
  • Drupal AI
  • Field API
  • Multilingual
  • JavaScript
  • Errors
  • professional development
  • Entity Query API
  • Mac OS
  • Drush
  • URL
  • Webform
  • Cache
  • Solar Power
  • RSA
  • Moderation
  • Coder
  • Bower
  • WSL2
  • Macbook
  • Lando
  • Permission
  • Bash Script
  • PHPSeclib
  • Articles
  • VSCode
  • Taxonomy
  • Drupal Behavior
  • Ajax API
  • Codesniffer
  • Drupal Console
  • phpcs
  • Solar Panel
  • Composer
  • Docker
  • jQuery
  • SEO
  • NPM
  • Workflow
  • Ubuntu
  • Views
  • Jellyfin
  • SSH
  • PHP
  • Android
  • Git
  • Twig
  • website
  • Neuron AI
  • MySQL
  • OOPs
  • kali
  • Commad Line Tools
  • Commad Line
  • Libraries
  • File API
  • Learning
  • Nginx
  • phpcbf
  • Drupal
  • Distribution
  • Linux
RSS Feed

Who am I !!!

Hari Venu V
harivenu.v1992@gmail.com
Mobile : +91 9895164181
Whatsapp : +91 9895164181
Linkedin
Drupal.org
Github

Document
Resume.pdf (114.38 KB)

Online Resume : Online Resume

Work !!!

Fulltime Developer @ QED42
hari.venu@qed42.com
Linkedin

Powered by Drupal & Maintained by Hari