condorrocks/condor

View on GitHub
app/helpers.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

use Carbon\Carbon;

if (!function_exists('setGlobalLocale')) {
    /**
     * Set locale among all localizable contexts.
     *
     * @param string $posixLocale
     *
     * @return void
     */
    function setGlobalLocale($posixLocale)
    {
        app()->setLocale($posixLocale);
        setlocale(LC_TIME, $posixLocale);
        Carbon::setLocale(locale_get_primary_language($posixLocale));
    }
}

if (!function_exists('isAcceptedLocale')) {
    /**
     * Determine if is a POSIX language string is accepted by app config.
     *
     * @param string $posixLocale Requested language
     *
     * @return bool Is an accepted language for this app
     */
    function isAcceptedLocale($posixLocale)
    {
        return array_key_exists($posixLocale, config('languages'));
    }
}