-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Time::humanize() does not work with ar locale #4708
Comments
No need to ping, I read every issue and respond according to my ability and time. I don't have much experience with Unicode string handling. Hopefully someone familiar will step in. |
I cannot reproduce that this works using the default locale $date = '٠١:٤٧:٢٨';
$time = (new DateTime())->modify($date);
var_dump($time); Unfortunately, this is not a CI4 bug. This is an inherent limitation of the |
@paulbalandan Sure, You right. But if we need to a multilingual system, humanize not work truly(for |
Yes, I understand what you want. But this issue is not limited to What I can see as a potential solution is to have first a converter to/from Arabic dates. Something like |
I've confirmed this bug. diff --git a/app/Config/App.php b/app/Config/App.php
index c6c716822..b697a23c5 100644
--- a/app/Config/App.php
+++ b/app/Config/App.php
@@ -70,7 +70,7 @@ class App extends BaseConfig
*
* @var string
*/
- public $defaultLocale = 'en';
+ public $defaultLocale = 'ar';
/**
* --------------------------------------------------------------------------
@@ -97,7 +97,7 @@ class App extends BaseConfig
*
* @var string[]
*/
- public $supportedLocales = ['en'];
+ public $supportedLocales = ['ar', 'en'];
/**
* --------------------------------------------------------------------------
diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php
index 7f867e95f..ff48fb5f2 100644
--- a/app/Controllers/Home.php
+++ b/app/Controllers/Home.php
@@ -6,6 +6,8 @@ class Home extends BaseController
{
public function index()
{
- return view('welcome_message');
+ $date = '2022-06-06';
+ $time = \CodeIgniter\I18n\Time::parse($date, 'America/Chicago');
+ return $time->humanize();
}
}
|
@perspolise But the output is like this:
Is this correct? (Added) |
I set arabic language in app config file for defualtLocale like this:
public $defaultLocale = 'ar';
Now, I work with
humanize
time function like this:Now in action I get this error:
I think the
DateTime
function have problem with arabic number. because when I seten
for default locale,humanize function
work truly.@lonnieezell @MGatner
The text was updated successfully, but these errors were encountered: