You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
557 B
27 lines
557 B
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
final class PortalLocale
|
|
{
|
|
public const ZH = 'zh-CN';
|
|
|
|
public const EN = 'en';
|
|
|
|
public const PORTAL_PARTICIPANT = 'participant';
|
|
|
|
public const PORTAL_AUDIENCE = 'audience';
|
|
|
|
public static function fromRequest(?string $lang): string
|
|
{
|
|
$value = strtolower(trim((string) $lang));
|
|
|
|
return $value === 'en' || $value === self::EN ? self::EN : self::ZH;
|
|
}
|
|
|
|
public static function isValid(string $locale): bool
|
|
{
|
|
return $locale === self::ZH || $locale === self::EN;
|
|
}
|
|
}
|