first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Prime\Translation;
final class EchoTranslator implements TranslatorInterface
{
/**
* {@inheritDoc}
*/
public function translate($id, $parameters = array(), $locale = null)
{
return $id;
}
/**
* {@inheritDoc}
*/
public function getLocale()
{
return 'en';
}
}

View File

@ -0,0 +1,63 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Prime\Translation;
final class Language
{
const LTR = 'ltr';
const RTL = 'rtl';
/**
* @param string $locale
*
* @return string
*/
public static function direction($locale)
{
if (!\extension_loaded('intl')) {
return self::LTR;
}
$resource = \ResourceBundle::create($locale, 'ICUDATA', true);
if (null === $resource) {
return self::LTR;
}
$layout = $resource->get('layout');
if (!$layout instanceof \ResourceBundle) {
return self::LTR;
}
$characters = $layout->get('characters');
if (!\is_string($characters)) {
return self::LTR;
}
return 'right-to-left' === $characters ? self::RTL : self::LTR;
}
/**
* @param string $locale
*
* @return bool
*/
public static function isRTL($locale)
{
return self::RTL === self::direction($locale);
}
/**
* @param string $locale
*
* @return bool
*/
public static function isLTR($locale)
{
return self::LTR === self::direction($locale);
}
}

View File

@ -0,0 +1,62 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Prime\Translation;
final class Messages
{
/**
* @var array<string, string>
*/
public static $ar = array(
'success' => 'نجاح',
'error' => 'خطأ',
'warning' => 'تحذير',
'info' => 'معلومة',
'The resource was created' => 'تم إنشاء :resource',
'The resource was updated' => 'تم تعديل :resource',
'The resource was saved' => 'تم حفظ :resource',
'The resource was deleted' => 'تم حذف :resource',
'resource' => 'الملف',
);
/**
* @var array<string, string>
*/
public static $en = array(
'success' => 'Success',
'error' => 'Error',
'warning' => 'Warning',
'info' => 'Info',
'The resource was created' => 'The :resource was created',
'The resource was updated' => 'The :resource was updated',
'The resource was saved' => 'The :resource was saved',
'The resource was deleted' => 'The :resource was deleted',
'resource' => 'resource',
);
/**
* @var array<string, string>
*/
public static $fr = array(
'success' => 'Succès',
'error' => 'Erreur',
'warning' => 'Avertissement',
'info' => 'Information',
'The resource was created' => 'La ressource :resource a été ajoutée',
'The resource was updated' => 'La ressource :resource a été mise à jour',
'The resource was saved' => 'La ressource :resource a été enregistrée',
'The resource was deleted' => 'La ressource :resource a été supprimée',
'resource' => '',
);
}

View File

@ -0,0 +1,21 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Prime\Translation;
interface ResourceInterface
{
/**
* @return string
*/
public function getResourceType();
/**
* @return string
*/
public function getResourceName();
}

View File

@ -0,0 +1,25 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Prime\Translation;
interface TranslatorInterface
{
/**
* @param string $id
* @param array<string, mixed> $parameters
* @param string|null $locale
*
* @return string
*/
public function translate($id, $parameters = array(), $locale = null);
/**
* @return string
*/
public function getLocale();
}