<?php

use languages\languages;


function languages()
{
    return new languages();
}

languages();

function pattern()
{
    return languages::$pattern;
}

function pattern_admin()
{
    return languages::$pattern_admin;
}

function msgs()
{
    return languages::$msgs;
}

function msg($key, $default = '')
{
    $msg = languages::$msgs;
    if (in_array($key, array_keys($msg))) {
        return $msg[$key];
    } else {
        return $default;
    }
}

function Getpattern($key, $default = '')
{
    $msg = languages::$pattern;
    if (in_array($key, array_keys($msg))) {
        return $msg[$key];
    } else {
        return $default;
    }
}

function patternAdmin($key, $default = '')
{
    $msg = languages::$pattern_admin;
    if (in_array($key, array_keys($msg))) {
        return $msg[$key];
    } else {
        return $default;
    }
}

function Check_pattern($text)
{
    foreach (languages::$pattern as $pt) {
        if (preg_match($pt, $text) || $pt == $text) {
            return 1;
        }
    }

    return false;
}

function Check_pattern_admin($text)
{
    foreach (languages::$pattern_admin as $pt) {
        if (preg_match($pt, $text) || $pt == $text) {
            return 1;
        }
    }

    return false;
}
