Fall back to base locale (i.e. de) if a countries specific locale (i.e. de-CH) is not available.

@param string $path
@param string $locale
@param string $group

@return array
359198
protected function loadPath($path, $locale, $group)
    {
        $result = parent::loadPath($path, $locale, $group);

        if (empty($result) && str_contains($locale, '-')) {
            return parent::loadPath($path, strstr($locale, '-', true), $group);
        }

        return $result;
    }
986330
public function setRouteGroup($path)
    {
        $group = $this->translator()->translation($path);

        foreach ($this->translator()->availableLocales() as $lang) {
            $group[$lang] = trim($group[$lang], '/');
        }

        $this->routeGroup = $group;

        return $this;
    }
729618
public function loadSource($locale, $group, $namespace = '*')
    {
        $dotArray = $this->translationRepository->loadSource($locale, $namespace, $group);
        $undot    = [];
        foreach ($dotArray as $item => $text) {
            array_set($undot, $item, $text);
        }
        return $undot;
    }
329352
public function findByCode($locale, $namespace, $group, $item)
    {
        return $this->model->whereLocale($locale)->whereNamespace($namespace)->whereGroup($group)->whereItem($item)->first();
    }
1157605
public function addTranslation($locale, $group, $key)
    {
        if(!\Config::get('app.debug') || \Config::get('translation-db.minimal')) return;

        // Extract the real key from the translation.
        if (preg_match("/^{$group}\.(.*?)$/sm", $key, $match)) {
            $name = $match[1];
        } else {
            throw new TranslationException('Could not extract key from translation.');
        }

        $item = \DB::table('translations')
            ->where('locale', $locale)
            ->where('group', $group)
            ->where('name', $name)->first();

        $data = compact('locale', 'group', 'name');
        $data = array_merge($data, [
            'viewed_at' => date_create(),
            'updated_at' => date_create(),
        ]);

        if($item === null) {
            $data = array_merge($data, [
                'created_at' => date_create(),
            ]);
            \DB::table('translations')->insert($data);
        } else {
            if($this->_app['config']->get('translation-db.update_viewed_at')) {
                \DB::table('translations')->where('id', $item->id)->update($data);
            }
        }
    }
222844
private function findRouteByPath($path, $locale)
    {
        $path = '/' . ltrim($path, '/');
        if (!array_key_exists($path, $this->routeCache)) {
            $this->routeCache[$path] = $this->routeRepository->findByPath($path, $locale);
        }

        return $this->routeCache[$path];
    }
779784
public function loadSource($locale, $namespace, $group)
    {
        return $this->model
            ->whereLocale($locale)
            ->whereNamespace($namespace)
            ->whereGroup($group)
            ->get()
            ->keyBy('item')
            ->map(function ($translation) {
                return $translation['text'];
            })
            ->toArray();
    }
1291193
protected function parseLocale($locale) {
        if (null == $locale) {
            return [$this->locale, $this->fallback];
        }

        return [$locale, $this->fallback];
    }
1196169
protected function loadLocalization( $domain, $path ) {
		if ( is_textdomain_loaded( $domain ) ) {
			return;
		}

		$locale = get_locale();

		/**
		 * Filter the locale of a Bright Nucleus library.
		 *
		 * @since v0.1.0
		 *
		 * @param string $locale The plugin's current locale.
		 * @param string $domain Text domain. Unique identifier for retrieving
		 *                       translated strings.
		 * @return string $locale Filtered locale.
		 */
		$locale = apply_filters(
			Localization::LOCALE_FILTER,
			$locale,
			$domain
		);

		/**
		 * Filter the name of the MO-file of a Bright Nucleus library.
		 *
		 * @since v0.1.0
		 *
		 * @param string $path   Path to the MO-file.
		 * @param string $locale The plugin's current locale.
		 * @param string $domain Text domain. Unique identifier for retrieving
		 *                       translated strings.
		 * @return string $path Filtered path to the MO-file.
		 */
		$mofile = apply_filters(
			Localization::MOFILE_FILTER,
			sprintf(
				'%1$s/%2$s-%3$s.mo',
				$path,
				$domain,
				$locale
			),
			$locale,
			$domain
		);

		return load_textdomain(
			$domain,
			$mofile
		);
	}
777456
protected function parseLocale($locale)
	{
		if ( ! is_null($locale))
		{
			return array_filter(array($locale, $this->fallback));
		}
		else
		{
			return array_filter(array($this->locale, $this->fallback));
		}
	}
130599
public static function setLocale($locale=null)
    {
        global $CFG, $TSUGI_LOCALE, $TSUGI_LOCALE_RELOAD;

        // No internationalization support
        if ( isset($CFG->legacytranslation) ) {
            if ( ! function_exists('bindtextdomain') ) return;
            if ( ! function_exists('textdomain') ) return;
        }

        if ( isset($CFG->legacytranslation) && $locale && 
            strpos($locale, 'UTF-8') === false ) $locale = $locale . '.UTF-8';

        if ( $locale === null && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) {

            if ( class_exists('\Locale') ) {
                try {
                    // Symfony may implement a stub for this function that throws an exception
                    $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
                } catch (exception $e) { }
            }
            if ($locale === null) { // Crude fallback if we can't use Locale::acceptFromHttp
                $pieces = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
                $locale = $pieces[0];
            }
        }

        if ( $locale === null && isset($CFG->fallbacklocale) && $CFG->fallbacklocale ) {
            $locale = $CFG->fallbacklocale;
        }

        if ( $locale === null ) return;

        $locale = str_replace('-','_',$locale);
        if ( isset($CFG->legacytranslation) ) {
            putenv('LC_ALL='.$locale);
            setlocale(LC_ALL, $locale);
        }
        // error_log("setLocale=$locale");
        if ( $TSUGI_LOCALE != $locale ) $TSUGI_LOCALE_RELOAD = true;
        $TSUGI_LOCALE = $locale;
    }
22531
public function load($locale, $group, $namespace = null)
    {
        if ($locale != $this->defaultLocale) {
            return array_replace_recursive(
                $this->loadSource($this->defaultLocale, $group, $namespace),
                $this->loadSource($locale, $group, $namespace)
            );
        }
        return $this->loadSource($locale, $group, $namespace);
    }
1327383
private function localeRoutes($router, $locale)
    {
        $this->app->setLocale($locale);

        $router->group(['namespace' => $this->namespace, 'prefix' => $locale], function ($router) {
            require app_path('Http/routes.php');
        });
    }
338915
public function forLocale($locale, $fallbacks=null)
    {
        $fork = $this->replicate()->setLocale($locale);

        if ($fallbacks) {
            return $fork->setFallbacks($fallbacks);
        }

        if ($this->localeFallbacks) {
            return $fork->setFallbacks($this->localeFallbacks);
        }

        return $fork;
    }
82000
public static function setFallbackLocale($locale)
    {
        $translator = static::getTranslator();

        if (method_exists($translator, 'setFallbackLocales')) {
            $translator->setFallbackLocales([$locale]);

            if ($translator instanceof Translator) {
                $preferredLocale = $translator->getLocale();
                $translator->setMessages($preferredLocale, array_replace_recursive(
                    $translator->getMessages()[$locale] ?? [],
                    Translator::get($locale)->getMessages()[$locale] ?? [],
                    $translator->getMessages($preferredLocale)
                ));
            }
        }
    }
20135
private function translate($path)
    {
        $value = $this->translator->translate($path, $this->environment->getDataDefinition()->getName());
        if ($path !== $value) {
            return $value;
        }

        return $this->translator->translate($path);
    }
195263
public function chgrp($path, $group = null, $recurse = false)
    {
        if (!file_exists($path)) {
            return false;
        }

        if (!isset($group)) {
            $group = $this->getDefaultGroup();
        }

        //Set chgrp for non-recursive request
        if (!$recurse) {
            return $this->chgrpReal($path, $group);
        }

        //Recursive chown
        return $this->chgrpRecurse($path, $group);
    }