/** * Includes CB text file * * @param string $langPath Path of the language folder (without trailing '/') * @param string $language ISO language (ISO 639-1 language code, a dash (-), then the ISO 3166-1 alpha-2 country code: e.g. 'en-GB') (which is also the name of the language folder) * @param string $filename Filename of the php language file (ending with '.php') * @param bool $fallback True (default): Falls back to default_language if $filename does not exist * @return bool True if language loaded successfully */ public static function import($langPath, $language, $filename, $fallback = true) { if (isset(static::$self->importedLangPathFiles[$language][$langPath][$filename])) { return true; } static::$self->loadLanguageFiles(); $file = $langPath . '/' . strtolower($language) . '/' . $filename; if (!file_exists($file)) { // If fallback is allowed, last resort is default_language without fallback: return $fallback && static::import($langPath, 'default_language', $filename, false); } $extension = substr($file, -4, 4); if ($extension == '.php') { /** @noinspection PhpIncludeInspection */ $strings = (include_once $file); } elseif ($extension == '.ini') { $strings = parse_ini_file($file, false); } else { return false; } if (!is_array($strings)) { return false; } /** @noinspection PhpDeprecationInspection */ static::addStrings($strings, $language); // Now if we already import other non-default languages, we also want to import this file in those other languages: if ($language != 'default_language' && count(static::$self->importedLangPathFiles) > 1) { foreach (array_keys(static::$self->importedLangPathFiles) as $la) { if ($la != 'default_language' && $la !== $language) { static::importSameInLanguage($la); } } } static::$self->importedLangPathFiles[$language][$langPath][$filename] = true; static::setCurrentLanguage($language); return true; }