From 894a090d1ce31bee3df32f59b51d7329e8767a51 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 29 Apr 2018 21:31:58 +0800 Subject: [PATCH] Add time lang file for getMonth helper, fixes #5 Month names now uses lang files Remove unused helper functions --- app/helpers.php | 55 ++++++++++++++++++---------------------------- resources/lang/en/time.php | 18 +++++++++++++++ resources/lang/id/time.php | 18 +++++++++++++++ 3 files changed, 57 insertions(+), 34 deletions(-) create mode 100644 resources/lang/en/time.php create mode 100644 resources/lang/id/time.php diff --git a/app/helpers.php b/app/helpers.php index a7588c1..9ef8840 100755 --- a/app/helpers.php +++ b/app/helpers.php @@ -46,7 +46,7 @@ function formatDate($date) return $explodedDate[2].'-'.$explodedDate[1].'-'.$explodedDate[0]; } - throw new App\Exceptions\InvalidDateException('Kesalahan format tanggal'); + throw new App\Exceptions\InvalidDateException('Invalid date format.'); } function dateId($date) @@ -63,7 +63,7 @@ function dateId($date) return $explodedDate[2].' '.$months[$explodedDate[1]].' '.$explodedDate[0]; } - throw new App\Exceptions\InvalidDateException('Kesalahan format tanggal'); + throw new App\Exceptions\InvalidDateException('Invalid date format.'); } function monthNumber($number) @@ -86,18 +86,18 @@ function monthId($monthNumber) function getMonths() { return [ - '01' => 'Januari', - '02' => 'Pebruari', - '03' => 'Maret', - '04' => 'April', - '05' => 'Mei', - '06' => 'Juni', - '07' => 'Juli', - '08' => 'Agustus', - '09' => 'September', - '10' => 'Oktober', - '11' => 'Nopember', - '12' => 'Desember', + '01' => __('time.month.01'), + '02' => __('time.month.02'), + '03' => __('time.month.03'), + '04' => __('time.month.04'), + '05' => __('time.month.05'), + '06' => __('time.month.06'), + '07' => __('time.month.07'), + '08' => __('time.month.08'), + '09' => __('time.month.09'), + '10' => __('time.month.10'), + '11' => __('time.month.11'), + '12' => __('time.month.12'), ]; } @@ -116,26 +116,13 @@ function str_split_ucwords($string) return ucwords(str_replace('_', ' ', $string)); } -function getDays() -{ - return $days = [1 => 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu']; -} - -function getDay($dayIndex = null) -{ - $days = getDays(); - if (!is_null($dayIndex) && in_array($dayIndex, range(1, 7))) { - return $days[$dayIndex]; - } - - return '-'; -} - -function sanitizeNumber($number) -{ - return str_replace(',', '.', $number); -} - +/** + * Convert file size to have unit string. + * + * @param int $bytes File size. + * + * @return string Converted file size with unit. + */ function formatSizeUnits($bytes) { if ($bytes >= 1073741824) { diff --git a/resources/lang/en/time.php b/resources/lang/en/time.php new file mode 100644 index 0000000..678da3a --- /dev/null +++ b/resources/lang/en/time.php @@ -0,0 +1,18 @@ + [ + '01' => 'January', + '02' => 'Februari', + '03' => 'March', + '04' => 'April', + '05' => 'May', + '06' => 'June', + '07' => 'July', + '08' => 'August', + '09' => 'September', + '10' => 'October', + '11' => 'November', + '12' => 'December', + ], +]; diff --git a/resources/lang/id/time.php b/resources/lang/id/time.php new file mode 100644 index 0000000..7bf6423 --- /dev/null +++ b/resources/lang/id/time.php @@ -0,0 +1,18 @@ + [ + '01' => 'Januari', + '02' => 'Pebruari', + '03' => 'Maret', + '04' => 'April', + '05' => 'Mei', + '06' => 'Juni', + '07' => 'Juli', + '08' => 'Agustus', + '09' => 'September', + '10' => 'Oktober', + '11' => 'Nopember', + '12' => 'Desember', + ], +];