Skip to content
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

Update Malay locale for v2 #1537

Merged
merged 2 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion outdatedLocales.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["ar", "fil", "fr-CH", "mk", "ms", "nl-BE"]
["ar", "fil", "fr-CH", "mk", "nl-BE"]
45 changes: 37 additions & 8 deletions src/locale/ms/_lib/formatLong/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
import buildFormatLongFn from '../../../_lib/buildFormatLongFn/index.js'

var formatLong = buildFormatLongFn({
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd, D MMMM YYYY HH:mm'
})
var dateFormats = {
full: 'EEEE, d MMMM yyyy',
long: 'd MMMM yyyy',
medium: 'd MMM yyyy',
short: 'd/M/yyyy'
}

var timeFormats = {
full: 'HH.mm.ss',
long: 'HH.mm.ss',
medium: 'HH.mm',
short: 'HH.mm'
}

var dateTimeFormats = {
full: "{{date}} 'pukul' {{time}}",
long: "{{date}} 'pukul' {{time}}",
medium: '{{date}}, {{time}}',
short: '{{date}}, {{time}}'
}

var formatLong = {
date: buildFormatLongFn({
formats: dateFormats,
defaultWidth: 'full'
}),

time: buildFormatLongFn({
formats: timeFormats,
defaultWidth: 'full'
}),

dateTime: buildFormatLongFn({
formats: dateTimeFormats,
defaultWidth: 'full'
})
}

export default formatLong
12 changes: 6 additions & 6 deletions src/locale/ms/_lib/formatRelative/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var formatRelativeLocale = {
lastWeek: 'dddd [lepas pada jam] LT',
yesterday: '[semalam pada jam] LT',
today: '[hari ini pada jam] LT',
tomorrow: '[esok pada jam] LT',
nextWeek: 'dddd [pada jam] LT',
other: 'L'
lastWeek: "eeee 'lepas pada jam' p",
yesterday: "'Semalam pada jam' p",
today: "'Hari ini pada jam' p",
tomorrow: "'Esok pada jam' p",
nextWeek: "eeee 'pada jam' p",
other: 'P'
}

export default function formatRelative(token, _date, _baseDate, _options) {
Expand Down
169 changes: 143 additions & 26 deletions src/locale/ms/_lib/localize/index.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,169 @@
import buildLocalizeFn from '../../../_lib/buildLocalizeFn/index.js'
import buildLocalizeArrayFn from '../../../_lib/buildLocalizeArrayFn/index.js'

// Most data for localization are taken from this page
// https://www.unicode.org/cldr/charts/32/summary/ms.html
var eraValues = {
narrow: ['SM', 'M'],
abbreviated: ['SM', 'M'],
wide: ['Sebelum Masihi', 'Masihi']
}

var quarterValues = {
narrow: ['1', '2', '3', '4'],
abbreviated: ['S1', 'S2', 'S3', 'S4'],
wide: ['Suku pertama', 'Suku kedua', 'Suku ketiga', 'Suku keempat']
}

// Note: in Malay, the names of days of the week and months are capitalized.
// If you are making a new locale based on this one, check if the same is true for the language you're working on.
// Generally, formatted dates should look like they are in the middle of a sentence,
// e.g. in Spanish language the weekdays and months should be in the lowercase.
var weekdayValues = {
narrow: ['Ah', 'Is', 'Se', 'Ra', 'Kh', 'Ju', 'Sa'],
short: ['Ahd', 'Isn', 'Sel', 'Rab', 'Kha', 'Jum', 'Sab'],
long: ['Ahad', 'Isnin', 'Selasa', 'Rabu', 'Khamis', 'Jumaat', 'Sabtu']
var monthValues = {
narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'O', 'S', 'O', 'N', 'D'],
abbreviated: [
'Jan',
'Feb',
'Mac',
'Apr',
'Mei',
'Jun',
'Jul',
'Ogo',
'Sep',
'Okt',
'Nov',
'Dis'
],
wide: [
'Januari',
'Februari',
'Mac',
'April',
'Mei',
'Jun',
'Julai',
'Ogos',
'September',
'Oktober',
'November',
'Disember'
]
}

var monthValues = {
short: ['Jan', 'Feb', 'Mac', 'Apr', 'Mei', 'Jun', 'Jul', 'Ogo', 'Sep', 'Okt', 'Nov', 'Dis'],
long: ['Januari', 'Februari', 'Mac', 'April', 'Mei', 'Jun', 'Julai', 'Ogos', 'September', 'Oktober', 'November', 'Disember']
var dayValues = {
narrow: ['A', 'I', 'S', 'R', 'K', 'J', 'S'],
short: ['Ahd', 'Isn', 'Sel', 'Rab', 'Kha', 'Jum', 'Sab'],
abbreviated: ['Ahd', 'Isn', 'Sel', 'Rab', 'Kha', 'Jum', 'Sab'],
wide: ['Ahad', 'Isnin', 'Selasa', 'Rabu', 'Khamis', 'Jumaat', 'Sabtu']
}

var timeOfDayValues = {
uppercase: ['AM', 'PM'],
lowercase: ['am', 'pm'],
long: ['a.m.', 'p.m.']
var dayPeriodValues = {
narrow: {
am: 'am',
pm: 'pm',
midnight: 'tgh malam',
noon: 'tgh hari',
morning: 'pagi',
afternoon: 'tengah hari',
evening: 'petang',
night: 'malam'
},
abbreviated: {
am: 'AM',
pm: 'PM',
midnight: 'tengah malam',
noon: 'tengah hari',
morning: 'pagi',
afternoon: 'tengah hari',
evening: 'petang',
night: 'malam'
},
wide: {
am: 'a.m.',
pm: 'p.m.',
midnight: 'tengah malam',
noon: 'tengah hari',
morning: 'pagi',
afternoon: 'tengah hari',
evening: 'petang',
night: 'malam'
}
}
var formattingDayPeriodValues = {
narrow: {
am: 'am',
pm: 'pm',
midnight: 'tengah malam',
noon: 'tengah hari',
morning: 'pagi',
afternoon: 'tengah hari',
evening: 'petang',
night: 'malam'
},
abbreviated: {
am: 'AM',
pm: 'PM',
midnight: 'tengah malam',
noon: 'tengah hari',
morning: 'pagi',
afternoon: 'tengah hari',
evening: 'petang',
night: 'malam'
},
wide: {
am: 'a.m.',
pm: 'p.m.',
midnight: 'tengah malam',
noon: 'tengah hari',
morning: 'pagi',
afternoon: 'tengah hari',
evening: 'petang',
night: 'malam'
}
}

function ordinalNumber (dirtyNumber) {
function ordinalNumber(dirtyNumber, _dirtyOptions) {
var number = Number(dirtyNumber)

// Can't use "pertama", "kedua" because can't be parsed
switch (number) {
case 1:
return 'pertama'
case 2:
return 'kedua'
case 3:
return 'ketiga'
default:
return 'ke-' + number
}
}

var localize = {
ordinalNumber: ordinalNumber,
weekday: buildLocalizeFn(weekdayValues, 'long'),
weekdays: buildLocalizeArrayFn(weekdayValues, 'long'),
month: buildLocalizeFn(monthValues, 'long'),
months: buildLocalizeArrayFn(monthValues, 'long'),
timeOfDay: buildLocalizeFn(timeOfDayValues, 'long', function (hours) {
return (hours / 12) >= 1 ? 1 : 0

era: buildLocalizeFn({
values: eraValues,
defaultWidth: 'wide'
}),
timesOfDay: buildLocalizeArrayFn(timeOfDayValues, 'long')

quarter: buildLocalizeFn({
values: quarterValues,
defaultWidth: 'wide',
argumentCallback: function(quarter) {
return Number(quarter) - 1
}
}),

month: buildLocalizeFn({
values: monthValues,
defaultWidth: 'wide'
}),

day: buildLocalizeFn({
values: dayValues,
defaultWidth: 'wide'
}),

dayPeriod: buildLocalizeFn({
values: dayPeriodValues,
defaultWidth: 'wide',
formattingValues: formattingDayPeriodValues,
defaultFormattingWidth: 'wide'
})
}

export default localize