public static function loadLanguageFile($strName, $strLanguage=null, $blnNoCache=false)
	{
		if ($strLanguage === null)
		{
			$strLanguage = str_replace('-', '_', $GLOBALS['TL_LANGUAGE'] ?? 'en');
		}

		// Fall back to English
		if ($strLanguage == '')
		{
			$strLanguage = 'en';
		}

		// Return if the language file has been loaded already
		if (isset(static::$arrLanguageFiles[$strName][$strLanguage]) && !$blnNoCache)
		{
			return;
		}

		$strCacheKey = $strLanguage;

		// Make sure the language exists
		if ($strLanguage != 'en' && !static::isInstalledLanguage($strLanguage))
		{
			$strShortLang = substr($strLanguage, 0, 2);

			// Fall back to "de" if "de_DE" does not exist
			if ($strShortLang != $strLanguage && static::isInstalledLanguage($strShortLang))
			{
				$strLanguage = $strShortLang;
			}

			// Fall back to English (see #6581)
			else
			{
				$strLanguage = 'en';
			}
		}

		// Use a global cache variable to support nested calls
		static::$arrLanguageFiles[$strName][$strCacheKey] = $strLanguage;

		// Fall back to English
		$arrCreateLangs = ($strLanguage == 'en') ? array('en') : array('en', $strLanguage);

		// Prepare the XLIFF loader
		$xlfLoader = new XliffFileLoader(static::getContainer()->getParameter('kernel.project_dir'), true);

		$strCacheDir = static::getContainer()->getParameter('kernel.cache_dir');

		// Load the language(s)
		foreach ($arrCreateLangs as $strCreateLang)
		{
			// Try to load from cache
			if (file_exists($strCacheDir . '/contao/languages/' . $strCreateLang . '/' . $strName . '.php'))
			{
				include $strCacheDir . '/contao/languages/' . $strCreateLang . '/' . $strName . '.php';
			}
			else
			{
				// Find the given filename either as .php or .xlf file
				$finder = static::getContainer()->get('contao.resource_finder')->findIn('languages/' . $strCreateLang)->name('/^' . $strName . '\.(php|xlf)$/');

				/** @var SplFileInfo $file */
				foreach ($finder as $file)
				{
					switch ($file->getExtension())
					{
						case 'php':
							include $file;
							break;

						case 'xlf':
							$xlfLoader->load($file, $strCreateLang);
							break;

						default:
							throw new \RuntimeException(sprintf('Invalid language file extension: %s', $file->getExtension()));
					}
				}
			}
		}

		// HOOK: allow to load custom labels
		if (isset($GLOBALS['TL_HOOKS']['loadLanguageFile']) && \is_array($GLOBALS['TL_HOOKS']['loadLanguageFile']))
		{
			foreach ($GLOBALS['TL_HOOKS']['loadLanguageFile'] as $callback)
			{
				static::importStatic($callback[0])->{$callback[1]}($strName, $strLanguage, $strCacheKey);
			}
		}

		// Handle single quotes in the deleteConfirm message
		if ($strName == 'default' && isset($GLOBALS['TL_LANG']['MSC']['deleteConfirm']))
		{
			$GLOBALS['TL_LANG']['MSC']['deleteConfirm'] = str_replace("'", "\\'", $GLOBALS['TL_LANG']['MSC']['deleteConfirm']);
		}

		$rootDir = self::getContainer()->getParameter('kernel.project_dir');

		// Local configuration file
		if (file_exists($rootDir . '/system/config/langconfig.php'))
		{
			@trigger_error('Using the langconfig.php file has been deprecated and will no longer work in Contao 5.0. Create one or more language files in app/Resources/contao/languages instead.', E_USER_DEPRECATED);
			include $rootDir . '/system/config/langconfig.php';
		}
	}
public static function loadLanguageFile($strName, $strLanguage=null, $blnNoCache=false)
	{
		if ($strLanguage === null)
		{
			$strLanguage = str_replace('-', '_', $GLOBALS['TL_LANGUAGE'] ?? 'en');
		}

		
		if ($strLanguage == '')
		{
			$strLanguage = 'en';
		}

		
		if (isset(static::$arrLanguageFiles[$strName][$strLanguage]) && !$blnNoCache)
		{
			return;
		}

		$strCacheKey = $strLanguage;

		
		if ($strLanguage != 'en' && !static::isInstalledLanguage($strLanguage))
		{
			$strShortLang = substr($strLanguage, 0, 2);

			
			if ($strShortLang != $strLanguage && static::isInstalledLanguage($strShortLang))
			{
				$strLanguage = $strShortLang;
			}

			
			else
			{
				$strLanguage = 'en';
			}
		}

		
		static::$arrLanguageFiles[$strName][$strCacheKey] = $strLanguage;

		
		$arrCreateLangs = ($strLanguage == 'en') ? array('en') : array('en', $strLanguage);

		
		$xlfLoader = new XliffFileLoader(static::getContainer()->getParameter('kernel.project_dir'), true);

		$strCacheDir = static::getContainer()->getParameter('kernel.cache_dir');

		
		foreach ($arrCreateLangs as $strCreateLang)
		{
			
			if (file_exists($strCacheDir . '/contao/languages/' . $strCreateLang . '/' . $strName . '.php'))
			{
				include $strCacheDir . '/contao/languages/' . $strCreateLang . '/' . $strName . '.php';
			}
			else
			{
				
				$finder = static::getContainer()->get('contao.resource_finder')->findIn('languages/' . $strCreateLang)->name('/^' . $strName . '\.(php|xlf)$/');

				
				foreach ($finder as $file)
				{
					switch ($file->getExtension())
					{
						case 'php':
							include $file;
							break;

						case 'xlf':
							$xlfLoader->load($file, $strCreateLang);
							break;

						default:
							throw new \RuntimeException(sprintf('Invalid language file extension: %s', $file->getExtension()));
					}
				}
			}
		}

		
		if (isset($GLOBALS['TL_HOOKS']['loadLanguageFile']) && \is_array($GLOBALS['TL_HOOKS']['loadLanguageFile']))
		{
			foreach ($GLOBALS['TL_HOOKS']['loadLanguageFile'] as $callback)
			{
				static::importStatic($callback[0])->{$callback[1]}($strName, $strLanguage, $strCacheKey);
			}
		}

		
		if ($strName == 'default' && isset($GLOBALS['TL_LANG']['MSC']['deleteConfirm']))
		{
			$GLOBALS['TL_LANG']['MSC']['deleteConfirm'] = str_replace("'", "\\'", $GLOBALS['TL_LANG']['MSC']['deleteConfirm']);
		}

		$rootDir = self::getContainer()->getParameter('kernel.project_dir');

		
		if (file_exists($rootDir . '/system/config/langconfig.php'))
		{
			@trigger_error('Using the langconfig.php file has been deprecated and will no longer work in Contao 5.0. Create one or more language files in app/Resources/contao/languages instead.', E_USER_DEPRECATED);
			include $rootDir . '/system/config/langconfig.php';
		}
	}
public static function loadLanguageFile ( $ strName , $ strLanguage = null , $ blnNoCache = false ) { if ( $ strLanguage === null ) { $ strLanguage = str_replace ( '-' , '_' , $ GLOBALS [ 'TL_LANGUAGE' ] ?? 'en' ) ; } // Fall back to English if ( $ strLanguage == '' ) { $ strLanguage = 'en' ; } // Return if the language file has been loaded already if ( isset ( static :: $ arrLanguageFiles [ $ strName ] [ $ strLanguage ] ) && ! $ blnNoCache ) { return ; } $ strCacheKey = $ strLanguage ; // Make sure the language exists if ( $ strLanguage != 'en' && ! static :: isInstalledLanguage ( $ strLanguage ) ) { $ strShortLang = substr ( $ strLanguage , 0 , 2 ) ; // Fall back to "de" if "de_DE" does not exist if ( $ strShortLang != $ strLanguage && static :: isInstalledLanguage ( $ strShortLang ) ) { $ strLanguage = $ strShortLang ; } // Fall back to English (see #6581) else { $ strLanguage = 'en' ; } } // Use a global cache variable to support nested calls static :: $ arrLanguageFiles [ $ strName ] [ $ strCacheKey ] = $ strLanguage ; // Fall back to English $ arrCreateLangs = ( $ strLanguage == 'en' ) ? array ( 'en' ) : array ( 'en' , $ strLanguage ) ; // Prepare the XLIFF loader $ xlfLoader = new XliffFileLoader ( static :: getContainer ( ) -> getParameter ( 'kernel.project_dir' ) , true ) ; $ strCacheDir = static :: getContainer ( ) -> getParameter ( 'kernel.cache_dir' ) ; // Load the language(s) foreach ( $ arrCreateLangs as $ strCreateLang ) { // Try to load from cache if ( file_exists ( $ strCacheDir . '/contao/languages/' . $ strCreateLang . '/' . $ strName . '.php' ) ) { include $ strCacheDir . '/contao/languages/' . $ strCreateLang . '/' . $ strName . '.php' ; } else { // Find the given filename either as .php or .xlf file $ finder = static :: getContainer ( ) -> get ( 'contao.resource_finder' ) -> findIn ( 'languages/' . $ strCreateLang ) -> name ( '/^' . $ strName . '\.(php|xlf)$/' ) ; /** @var SplFileInfo $file */ foreach ( $ finder as $ file ) { switch ( $ file -> getExtension ( ) ) { case 'php' : include $ file ; break ; case 'xlf' : $ xlfLoader -> load ( $ file , $ strCreateLang ) ; break ; default : throw new \ RuntimeException ( sprintf ( 'Invalid language file extension: %s' , $ file -> getExtension ( ) ) ) ; } } } } // HOOK: allow to load custom labels if ( isset ( $ GLOBALS [ 'TL_HOOKS' ] [ 'loadLanguageFile' ] ) && \ is_array ( $ GLOBALS [ 'TL_HOOKS' ] [ 'loadLanguageFile' ] ) ) { foreach ( $ GLOBALS [ 'TL_HOOKS' ] [ 'loadLanguageFile' ] as $ callback ) { static :: importStatic ( $ callback [ 0 ] ) -> { $ callback [ 1 ] } ( $ strName , $ strLanguage , $ strCacheKey ) ; } } // Handle single quotes in the deleteConfirm message if ( $ strName == 'default' && isset ( $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'deleteConfirm' ] ) ) { $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'deleteConfirm' ] = str_replace ( "'" , "\\'" , $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'deleteConfirm' ] ) ; } $ rootDir = self :: getContainer ( ) -> getParameter ( 'kernel.project_dir' ) ; // Local configuration file if ( file_exists ( $ rootDir . '/system/config/langconfig.php' ) ) { @ trigger_error ( 'Using the langconfig.php file has been deprecated and will no longer work in Contao 5.0. Create one or more language files in app/Resources/contao/languages instead.' , E_USER_DEPRECATED ) ; include $ rootDir . '/system/config/langconfig.php' ; } }
Load a set of language files

@param string  $strName     The table name
@param boolean $strLanguage An optional language code
@param boolean $blnNoCache  If true, the cache will be bypassed
Load a set of language files