briannesbitt / Carbon

A simple PHP API extension for DateTime.
https://carbon.nesbot.com/
MIT License
16.57k stars 1.28k forks source link

[Translation tool] ms #2433

Closed hairulf closed 3 years ago

hairulf commented 3 years ago

Additional fixes

afternoon -> change to 'petang' instead of 'tengah hari'


'Tengah hari' is noon

hairulf commented 3 years ago

If possible, please correct it ASAP. We are currently working on government app & they keep on harassing us... 😅

kylekatarnls commented 3 years ago

Hello, thanks for the report,

First thing is we're in any rush because you can easily customize the translations for a given language:

\Carbon\Translator::get('ms')->setTranslations([
    'meridiem' => function ($hour, $minute) {
        if ($hour < 12) {
            return 'pagi';
        }

        if ($hour < 19) {
            return 'petang';
        }

        return 'malam';
    },
]);

echo Carbon::parse('2021-08-24 13:00')->locale('ms')->isoFormat('a');

Second, please provide some explanation and source references so as a non-speaker I can check the relevance of the change in the different contextes where it can be used.

Thanks,

kylekatarnls commented 3 years ago

For the record, we have "tengah hari" from 12:00 to 14:59 which looks correct (and was taken from CLDR if I recall correctly): https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Lang/ms.php#L81

hairulf commented 3 years ago

Hi @kylekatarnls ,

Thanks for the prompt reply.

Now that you've shown me the source, it clears things up. My initial thought it was to represent PM only.

But still, it is uncommon in Malaysia to call "Tengah hari" when it is pass 1pm.

'Tengah' means 'middle' 'Hari' means 'day'

So, literally, 'Tengah hari' means 'middle of the day' and it is only used for 12 pm only. It goes the same to 'Tengah malam' for 12 am, but it is not a big deal rather than 'Tengah hari'.

The best solution I would suggest is:

'meridiem' => function ($hour) {
        **if ($hour > 0 && $hour < 1) {
            return 'tengah malam';
        }**
        if ($hour < 12) {
            return 'pagi';
        }
        if ($hour < **13**) {
            return 'tengah hari';
        }
        if ($hour < 19) {
            return 'petang';
        }

        return 'malam';
    },
If you can approve this, I believe many would be happy.

Thanks again for your time and attention.
hairulf commented 3 years ago

I attached here some official reference from our national Bahasa Melayu curator, Dewan Bahasa & Pustaka (DBP)

FB_IMG_1614076429068

I can't find an article from the official website but these QA and advices from the people of DBP gave similar answer. The keyword to find is 'Sistem Pemenggalan Waktu'

https://prpm.dbp.gov.my/Cari1?keyword=pemenggalan+waktu&d=175768&#LIHATSINI