Skip to content

Commit

Permalink
[l10n] Add Basque (eu) locale and improve Spanish (es-ES) locale (mui…
Browse files Browse the repository at this point in the history
…#10985)

Co-authored-by: Lajto 理德 <[email protected]>
Co-authored-by: David Andrés <[email protected]>
  • Loading branch information
3 people authored Nov 10, 2023
1 parent 9cd93ce commit 9ec35c4
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 16 deletions.
10 changes: 9 additions & 1 deletion docs/data/date-pickers/localization/data.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[
{
"languageTag": "eu",
"importName": "eu",
"localeName": "Basque",
"missingKeysCount": 0,
"totalKeysCount": 37,
"githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-date-pickers/src/locales/eu.ts"
},
{
"languageTag": "be-BY",
"importName": "beBY",
Expand Down Expand Up @@ -203,7 +211,7 @@
"languageTag": "es-ES",
"importName": "esES",
"localeName": "Spanish",
"missingKeysCount": 1,
"missingKeysCount": 0,
"totalKeysCount": 37,
"githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-date-pickers/src/locales/esES.ts"
},
Expand Down
18 changes: 9 additions & 9 deletions packages/x-date-pickers/src/locales/esES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const esESPickers: Partial<PickersLocaleText<any>> = {
clockLabelText: (view, time, adapter) =>
`Seleccione ${views[view]}. ${
time === null
? 'Sin tiempo seleccionado'
: `El tiempo seleccionado es ${adapter.format(time, 'fullTime')}`
? 'No hay hora seleccionada'
: `La hora seleccionada es ${adapter.format(time, 'fullTime')}`
}`,
hoursClockNumberText: (hours) => `${hours} horas`,
minutesClockNumberText: (minutes) => `${minutes} minutos`,
Expand All @@ -61,17 +61,17 @@ const esESPickers: Partial<PickersLocaleText<any>> = {
// Open picker labels
openDatePickerDialogue: (value, utils) =>
value !== null && utils.isValid(value)
? `Elige la fecha, la fecha elegida es ${utils.format(value, 'fullDate')}`
: 'Elige la fecha',
? `Elige fecha, la fecha elegida es ${utils.format(value, 'fullDate')}`
: 'Elige fecha',
openTimePickerDialogue: (value, utils) =>
value !== null && utils.isValid(value)
? `Elige la hora, la hora elegido es ${utils.format(value, 'fullTime')}`
: 'Elige la hora',
// fieldClearLabel: 'Clear value',
? `Elige hora, la hora elegida es ${utils.format(value, 'fullTime')}`
: 'Elige hora',
fieldClearLabel: 'Limpiar valor',

// Table labels
timeTableLabel: 'elige la fecha',
dateTableLabel: 'elige la hora',
timeTableLabel: 'elige hora',
dateTableLabel: 'elige fecha',

// Field section placeholders
fieldYearPlaceholder: (params) => 'A'.repeat(params.digitAmount),
Expand Down
87 changes: 87 additions & 0 deletions packages/x-date-pickers/src/locales/eu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { PickersLocaleText } from './utils/pickersLocaleTextApi';
import { getPickersLocalization } from './utils/getPickersLocalization';
import { TimeViewWithMeridiem } from '../internals/models';

const views: Record<TimeViewWithMeridiem, string> = {
hours: 'orduak',
minutes: 'minutuak',
seconds: 'segunduak',
meridiem: 'meridianoa',
};

const euPickers: Partial<PickersLocaleText<any>> = {
// Calendar navigation
previousMonth: 'Azken hilabetea',
nextMonth: 'Hurrengo hilabetea',

// View navigation
openPreviousView: 'azken bista ireki',
openNextView: 'hurrengo bista ireki',
calendarViewSwitchingButtonAriaLabel: (view) =>
view === 'year'
? 'urteko bista irekita dago, aldatu egutegi bistara'
: 'egutegi bista irekita dago, aldatu urteko bistara',

// DateRange placeholders
start: 'Hasi',
end: 'Bukatu',

// Action bar
cancelButtonLabel: 'Utxi',
clearButtonLabel: 'Garbitu',
okButtonLabel: 'OK',
todayButtonLabel: 'Gaur',

// Toolbar titles
datePickerToolbarTitle: 'Data aukeratu',
dateTimePickerToolbarTitle: 'Data eta ordua aukeratu',
timePickerToolbarTitle: 'Ordua aukeratu',
dateRangePickerToolbarTitle: 'Data tartea aukeratu',

// Clock labels
clockLabelText: (view, time, adapter) =>
`Aukeratu ${views[view]}. ${
time === null
? 'Ez da ordurik aukertau'
: `Aukeratutako ordua ${adapter.format(time, 'fullTime')} da`
}`,
hoursClockNumberText: (hours) => `${hours} ordu`,
minutesClockNumberText: (minutes) => `${minutes} minutu`,
secondsClockNumberText: (seconds) => `${seconds} segundu`,

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

// Calendar labels
calendarWeekNumberHeaderLabel: 'Astea zenbakia',
calendarWeekNumberHeaderText: '#',
calendarWeekNumberAriaLabelText: (weekNumber) => `${weekNumber} astea`,
calendarWeekNumberText: (weekNumber) => `${weekNumber}`,

// Open picker labels
openDatePickerDialogue: (value, utils) =>
value !== null && utils.isValid(value)
? `Data aukeratu, aukeratutako data ${utils.format(value, 'fullDate')} da`
: 'Data aukeratu',
openTimePickerDialogue: (value, utils) =>
value !== null && utils.isValid(value)
? `Ordua aukeratu, aukeratutako ordua ${utils.format(value, 'fullTime')} da`
: 'Ordua aukeratu',
fieldClearLabel: 'Balioa garbitu',

// Table labels
timeTableLabel: 'ordua aukeratu',
dateTableLabel: 'data aukeratu',

// Field section placeholders
fieldYearPlaceholder: (params) => 'Y'.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',
};

export const eu = getPickersLocalization(euPickers);
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 @@ -5,6 +5,7 @@ export * from './deDE';
export * from './elGR';
export * from './enUS';
export * from './esES';
export * from './eu';
export * from './faIR';
export * from './fiFI';
export * from './frFR';
Expand Down
16 changes: 10 additions & 6 deletions scripts/l10n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function plugin(existingTranslations: Translations): babel.PluginObj {
}

// Test if the variable name follows the pattern xxXXGrid or xxXXPickers
if (!/[a-z]{2}[A-Z]{2}(Grid|Pickers)/.test(node.id.name)) {
if (!/[a-z]{2}[A-Z]{2}|[a-z]{2}(Grid|Pickers)/.test(node.id.name)) {
visitorPath.skip();
return;
}
Expand Down Expand Up @@ -164,7 +164,7 @@ function extractTranslations(translationsPath: string): [TranslationsByGroup, Tr
function findLocales(localesDirectory: string, constantsPath: string) {
const items = fse.readdirSync(localesDirectory);
const locales: any[] = [];
const localeRegex = /^[a-z]{2}[A-Z]{2}/;
const localeRegex = /^[a-z]{2}[A-Z]{2}|^[a-z]{2}(?=.ts)/;

items.forEach((item) => {
const match = item.match(localeRegex);
Expand All @@ -173,7 +173,10 @@ function findLocales(localesDirectory: string, constantsPath: string) {
}

const localePath = path.resolve(localesDirectory, item);
const code = match[0];
if (fse.lstatSync(localePath).isDirectory()) {
return;
}
const code = match[0] || match[1];
if (constantsPath !== localePath) {
// Ignore the locale used as a reference
locales.push([localePath, code]);
Expand Down Expand Up @@ -321,9 +324,10 @@ const generateDocReport = async (
return;
}

const languageTag = `${importName.slice(0, 2).toLowerCase()}-${importName
.slice(2)
.toUpperCase()}`;
const languageTag =
importName.length > 2
? `${importName.slice(0, 2).toLowerCase()}-${importName.slice(2).toUpperCase()}`
: importName;
const localeName = localeNames[languageTag];

if (localeName === undefined) {
Expand Down
1 change: 1 addition & 0 deletions scripts/localeNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
'hy-AM': 'Armenian',
'az-AZ': 'Azerbaijani',
'bn-BD': 'Bangla',
eu: 'Basque',
'be-BY': 'Belarusian',
'bg-BG': 'Bulgarian',
'ca-ES': 'Catalan',
Expand Down
1 change: 1 addition & 0 deletions scripts/x-date-pickers-pro.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
{ "name": "elGR", "kind": "Variable" },
{ "name": "enUS", "kind": "Variable" },
{ "name": "esES", "kind": "Variable" },
{ "name": "eu", "kind": "Variable" },
{ "name": "ExportedDateRangeCalendarProps", "kind": "Interface" },
{ "name": "ExportedDigitalClockProps", "kind": "Interface" },
{ "name": "ExportedMultiSectionDigitalClockSectionProps", "kind": "Interface" },
Expand Down
1 change: 1 addition & 0 deletions scripts/x-date-pickers.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
{ "name": "elGR", "kind": "Variable" },
{ "name": "enUS", "kind": "Variable" },
{ "name": "esES", "kind": "Variable" },
{ "name": "eu", "kind": "Variable" },
{ "name": "ExportedDigitalClockProps", "kind": "Interface" },
{ "name": "ExportedMultiSectionDigitalClockSectionProps", "kind": "Interface" },
{ "name": "ExportedPickersCalendarHeaderProps", "kind": "TypeAlias" },
Expand Down

0 comments on commit 9ec35c4

Please sign in to comment.