Skip to content

Commit

Permalink
[l10n] Add Croatian (hr-HR) locale (#14795)
Browse files Browse the repository at this point in the history
  • Loading branch information
arminmeh authored Oct 1, 2024
1 parent a4eaf65 commit 539a7ba
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/data/date-pickers/localization/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
"totalKeysCount": 50,
"githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-date-pickers/src/locales/zhCN.ts"
},
{
"languageTag": "hr-HR",
"importName": "hrHR",
"localeName": "Croatian",
"missingKeysCount": 0,
"totalKeysCount": 50,
"githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-date-pickers/src/locales/hrHR.ts"
},
{
"languageTag": "cs-CZ",
"importName": "csCZ",
Expand Down
118 changes: 118 additions & 0 deletions packages/x-date-pickers/src/locales/hrHR.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { PickersLocaleText } from './utils/pickersLocaleTextApi';
import { getPickersLocalization } from './utils/getPickersLocalization';
import { TimeViewWithMeridiem } from '../internals/models';

// maps TimeView to its translation
const timeViews: Record<TimeViewWithMeridiem, string> = {
hours: 'sati',
minutes: 'minute',
seconds: 'sekunde',
meridiem: 'meridiem',
};

const hrHRPickers: Partial<PickersLocaleText<any>> = {
// Calendar navigation
previousMonth: 'Prethodni mjesec',
nextMonth: 'Naredni mjesec',

// View navigation
openPreviousView: 'Otvori prethodni prikaz',
openNextView: 'Otvori naredni prikaz',
calendarViewSwitchingButtonAriaLabel: (view) =>
view === 'year'
? 'Otvoren je godišnji prikaz, promijeni na kalendarski prikaz'
: 'Otvoren je kalendarski prikaz, promijeni na godišnji prikaz',

// DateRange labels
start: 'Početak',
end: 'Kraj',
startDate: 'Početni datum',
startTime: 'Početno vrijeme',
endDate: 'Krajnji datum',
endTime: 'Krajnje vrijeme',

// Action bar
cancelButtonLabel: 'Otkaži',
clearButtonLabel: 'Izbriši',
okButtonLabel: 'U redu',
todayButtonLabel: 'Danas',

// Toolbar titles
datePickerToolbarTitle: 'Odaberi datum',
dateTimePickerToolbarTitle: 'Odaberi datum i vrijeme',
timePickerToolbarTitle: 'Odaberi vrijeme',
dateRangePickerToolbarTitle: 'Odaberi vremenski okvir',

// Clock labels
clockLabelText: (view, time, utils, formattedTime) =>
`Odaberi ${timeViews[view] ?? view}. ${!formattedTime && (time === null || !utils.isValid(time)) ? 'Vrijeme nije odabrano' : `Odabrano vrijeme je ${formattedTime ?? utils.format(time, 'fullTime')}`}`,
hoursClockNumberText: (hours) => {
let suffix = 'sati';
if (Number(hours) === 1) {
suffix = 'sat';
} else if (Number(hours) < 5) {
suffix = 'sata';
}
return `${hours} ${suffix}`;
},
minutesClockNumberText: (minutes) =>
`${minutes} ${Number(minutes) > 1 && Number(minutes) < 5 ? 'minute' : 'minuta'}`,
secondsClockNumberText: (seconds) => {
let suffix = 'sekundi';
if (Number(seconds) === 1) {
suffix = 'sekunda';
} else if (Number(seconds) < 5) {
suffix = 'sekunde';
}
return `${seconds} ${suffix}`;
},

// Digital clock labels
selectViewText: (view) => `Odaberi ${timeViews[view]}`,

// Calendar labels
calendarWeekNumberHeaderLabel: 'Broj tjedna',
calendarWeekNumberHeaderText: '#',
calendarWeekNumberAriaLabelText: (weekNumber) => `Tjedan ${weekNumber}`,
calendarWeekNumberText: (weekNumber) => `${weekNumber}`,

// Open picker labels
openDatePickerDialogue: (value, utils, formattedDate) =>
formattedDate || (value !== null && utils.isValid(value))
? `Odaberi datum, odabrani datum je ${formattedDate ?? utils.format(value, 'fullDate')}`
: 'Odaberi datum',
openTimePickerDialogue: (value, utils, formattedTime) =>
formattedTime || (value !== null && utils.isValid(value))
? `Odaberi vrijeme, odabrano vrijeme je ${formattedTime ?? utils.format(value, 'fullTime')}`
: 'Odaberi vrijeme',
fieldClearLabel: 'Izbriši',

// Table labels
timeTableLabel: 'Odaberi vrijeme',
dateTableLabel: 'Odaberi datum',

// Field section placeholders
fieldYearPlaceholder: (params) => 'G'.repeat(params.digitAmount),
fieldMonthPlaceholder: (params) => (params.contentType === 'letter' ? 'MMMM' : 'MM'),
fieldDayPlaceholder: () => 'DD',
fieldWeekDayPlaceholder: (params) => (params.contentType === 'letter' ? 'EEEE' : 'EE'),
fieldHoursPlaceholder: () => 'hh',
fieldMinutesPlaceholder: () => 'mm',
fieldSecondsPlaceholder: () => 'ss',
fieldMeridiemPlaceholder: () => 'aa',

// View names
year: 'Godina',
month: 'Mjesec',
day: 'Dan',
weekDay: 'Dan u tjednu',
hours: 'Sati',
minutes: 'Minute',
seconds: 'Sekunde',
meridiem: 'Meridiem',

// Common
empty: 'Isprazni',
};

export const hrHR = getPickersLocalization(hrHRPickers);
1 change: 1 addition & 0 deletions packages/x-date-pickers/src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './faIR';
export * from './fiFI';
export * from './frFR';
export * from './heIL';
export * from './hrHR';
export * from './huHU';
export * from './isIS';
export * from './itIT';
Expand Down

0 comments on commit 539a7ba

Please sign in to comment.