From 713e4f10d2db2f1939fbd36a71f49e6221c33ea6 Mon Sep 17 00:00:00 2001 From: Dylan Kilgore Date: Thu, 20 Apr 2023 15:29:32 -0700 Subject: [PATCH] fix: locale: add support for hi locale --- .../ConfigProvider/ConfigProvider.stories.tsx | 9 ++- .../DatePicker/Locale/hi_IN.tsx | 24 ++++++ .../DateTimePicker/Internal/Generate/dayjs.ts | 1 + .../DateTimePicker/Internal/Locale/hi_IN.ts | 32 ++++++++ .../TimePicker/Locale/hi_IN.tsx | 7 ++ .../Dialog/BaseDialog/Locale/hi_IN.tsx | 12 +++ src/components/InfoBar/Locale/hi_IN.tsx | 10 +++ src/components/Locale/hi_IN.tsx | 81 +++++++++++++++++++ .../Tests/__snapshots__/index.test.js.snap | 10 +++ .../LocaleProvider/Tests/index.test.js | 2 + src/components/LocaleProvider/hi_IN.tsx | 3 + src/components/Pagination/Locale/hi_IN.tsx | 18 +++++ src/components/Panel/Locale/hi_IN.tsx | 10 +++ src/components/Stepper/Locale/hi_IN.tsx | 15 ++++ src/components/Table/Locale/hi_IN.tsx | 25 ++++++ src/components/Upload/Locale/hi_IN.tsx | 28 +++++++ 16 files changed, 283 insertions(+), 4 deletions(-) create mode 100644 src/components/DateTimePicker/DatePicker/Locale/hi_IN.tsx create mode 100644 src/components/DateTimePicker/Internal/Locale/hi_IN.ts create mode 100644 src/components/DateTimePicker/TimePicker/Locale/hi_IN.tsx create mode 100644 src/components/Dialog/BaseDialog/Locale/hi_IN.tsx create mode 100644 src/components/InfoBar/Locale/hi_IN.tsx create mode 100644 src/components/Locale/hi_IN.tsx create mode 100644 src/components/LocaleProvider/hi_IN.tsx create mode 100644 src/components/Pagination/Locale/hi_IN.tsx create mode 100644 src/components/Panel/Locale/hi_IN.tsx create mode 100644 src/components/Stepper/Locale/hi_IN.tsx create mode 100644 src/components/Table/Locale/hi_IN.tsx create mode 100644 src/components/Upload/Locale/hi_IN.tsx diff --git a/src/components/ConfigProvider/ConfigProvider.stories.tsx b/src/components/ConfigProvider/ConfigProvider.stories.tsx index e9aec2b3d..32699bb10 100644 --- a/src/components/ConfigProvider/ConfigProvider.stories.tsx +++ b/src/components/ConfigProvider/ConfigProvider.stories.tsx @@ -58,7 +58,7 @@ import frBE from '../Locale/fr_BE'; // Français (Belgium) TODO: dayjs has no fr import frCA from '../Locale/fr_CA'; // Français (Canada) import frFR from '../Locale/fr_FR'; // Français import heIL from '../Locale/he_IL'; // עברית -// import hiHI from '../Locale/hi_HI'; // हिंदी TODO: Add Hindi locale +import hiIN from '../Locale/hi_IN'; // हिंदी import hrHR from '../Locale/hr_HR'; // Hrvatski import htHT from '../Locale/ht_HT'; // Haitian import huHU from '../Locale/hu_HU'; // Magyar @@ -94,7 +94,7 @@ import 'dayjs/locale/fi'; import 'dayjs/locale/fr'; // Use fr for fr-BE too import 'dayjs/locale/fr-ca'; import 'dayjs/locale/he'; -// import 'dayjs/locale/hi'; uncomment when Hindi locale is added +import 'dayjs/locale/hi'; import 'dayjs/locale/hr'; import 'dayjs/locale/ht'; import 'dayjs/locale/hu'; @@ -639,7 +639,7 @@ const localeValues: string[] = [ 'fr_CA', 'fr_FR', 'he_IL', - // 'hi_HI', + 'hi_IN', 'hr_HR', 'ht_HT', 'hu_HU', @@ -703,7 +703,7 @@ const Locale_Story: ComponentStory = (args) => { fr_CA: frCA, fr_FR: frFR, he_IL: heIL, - // 'hi_HI': hiHI, + hi_IN: hiIN, hr_HR: hrHR, ht_HT: htHT, hu_HU: huHU, @@ -742,6 +742,7 @@ const Locale_Story: ComponentStory = (args) => { fr_CA: 'fr-ca', fr_FR: 'fr', he_IL: 'he', + hi_IN: 'hi', hr_HR: 'hr', ht_HT: 'ht', hu_HU: 'hu', diff --git a/src/components/DateTimePicker/DatePicker/Locale/hi_IN.tsx b/src/components/DateTimePicker/DatePicker/Locale/hi_IN.tsx new file mode 100644 index 000000000..2bd992794 --- /dev/null +++ b/src/components/DateTimePicker/DatePicker/Locale/hi_IN.tsx @@ -0,0 +1,24 @@ +import CalendarLocale from '../../Internal/Locale/hi_IN'; +import TimePickerLocale from '../../TimePicker/Locale/hi_IN'; +import type { PickerLocale } from '../Generate/Generate.types'; + +const locale: PickerLocale = { + lang: { + placeholder: 'दिनांक का चयन करें', + yearPlaceholder: 'वर्ष का चयन करें', + quarterPlaceholder: 'तिमाही का चयन करें', + monthPlaceholder: 'महीने का चयन करें', + weekPlaceholder: 'सप्ताह का चयन करें', + rangePlaceholder: ['प्रारंभ दिनांक', 'समाप्ति दिनांक'], + rangeYearPlaceholder: ['वर्ष प्रारंभ करें', 'वर्ष के अंत में'], + rangeQuarterPlaceholder: ['प्रारंभ तिमाही', 'अंत तिमाही'], + rangeMonthPlaceholder: ['महीना शुरू करें', 'अंत माह'], + rangeWeekPlaceholder: ['सप्ताह की शुरुआत', 'सप्ताह के अंत में'], + ...CalendarLocale, + }, + timePickerLocale: { + ...TimePickerLocale, + }, +}; + +export default locale; diff --git a/src/components/DateTimePicker/Internal/Generate/dayjs.ts b/src/components/DateTimePicker/Internal/Generate/dayjs.ts index a36e365f9..1b3dc16e1 100644 --- a/src/components/DateTimePicker/Internal/Generate/dayjs.ts +++ b/src/components/DateTimePicker/Internal/Generate/dayjs.ts @@ -43,6 +43,7 @@ const localeMap: IlocaleMapObject = { fr_CA: 'fr-ca', // Français (Canada) fr_FR: 'fr', // Français he_IL: 'he', // עברית + hi_IN: 'hi', // हिंदी hr_HR: 'hr', // Hrvatski ht_HT: 'ht', // Haitian hu_HU: 'hu', // Magyar diff --git a/src/components/DateTimePicker/Internal/Locale/hi_IN.ts b/src/components/DateTimePicker/Internal/Locale/hi_IN.ts new file mode 100644 index 000000000..8785da178 --- /dev/null +++ b/src/components/DateTimePicker/Internal/Locale/hi_IN.ts @@ -0,0 +1,32 @@ +import type { Locale } from '../OcPicker.types'; + +const locale: Locale = { + locale: 'hi_IN', + backToToday: 'आज पर लौटें', + clear: 'स्पष्ट', + dateFormat: 'D/M/YYYY', + dateSelect: 'दिनांक का चयन करें', + dateTimeFormat: 'D/M/YYYY HH:mm:ss', + dayFormat: 'D', + decadeSelect: 'एक दशक चुनें', + month: 'महीना', + monthBeforeYear: true, + monthSelect: 'एक महीना चुनें', + nextCentury: 'अगली सदी', + nextDecade: 'अगले दशक', + nextMonth: 'अगले दशक (PageDown)', + nextYear: 'अगले साल (Control + right)', + now: 'अब', + ok: 'ठीक है', + previousCentury: 'पिछली सदी', + previousDecade: 'पिछले दशक', + previousMonth: 'पिछले महीने (PageUp)', + previousYear: 'पिछले साल (Control + left)', + timeSelect: 'समय का चयन करें', + today: 'आज', + year: 'साल', + yearFormat: 'YYYY', + yearSelect: 'एक वर्ष चुनें', +}; + +export default locale; diff --git a/src/components/DateTimePicker/TimePicker/Locale/hi_IN.tsx b/src/components/DateTimePicker/TimePicker/Locale/hi_IN.tsx new file mode 100644 index 000000000..12f940c07 --- /dev/null +++ b/src/components/DateTimePicker/TimePicker/Locale/hi_IN.tsx @@ -0,0 +1,7 @@ +import type { TimePickerLocale } from '../TimePicker.types'; + +const locale: TimePickerLocale = { + placeholder: 'समय का चयन करें', +}; + +export default locale; diff --git a/src/components/Dialog/BaseDialog/Locale/hi_IN.tsx b/src/components/Dialog/BaseDialog/Locale/hi_IN.tsx new file mode 100644 index 000000000..edabe9940 --- /dev/null +++ b/src/components/Dialog/BaseDialog/Locale/hi_IN.tsx @@ -0,0 +1,12 @@ +import type { DialogLocale } from '../BaseDialog.types'; + +const locale: DialogLocale = { + lang: { + locale: 'hi_IN', + cancelText: 'रद्द करना', + closeButtonAriaLabelText: 'बंद करना', + okText: 'ठीक है', + }, +}; + +export default locale; diff --git a/src/components/InfoBar/Locale/hi_IN.tsx b/src/components/InfoBar/Locale/hi_IN.tsx new file mode 100644 index 000000000..66981aa26 --- /dev/null +++ b/src/components/InfoBar/Locale/hi_IN.tsx @@ -0,0 +1,10 @@ +import type { InfoBarLocale } from '../InfoBar.types'; + +const locale: InfoBarLocale = { + lang: { + locale: 'hi_IN', + closeButtonAriaLabelText: 'बंद करना', + }, +}; + +export default locale; diff --git a/src/components/Locale/hi_IN.tsx b/src/components/Locale/hi_IN.tsx new file mode 100644 index 000000000..70efb7135 --- /dev/null +++ b/src/components/Locale/hi_IN.tsx @@ -0,0 +1,81 @@ +/* eslint-disable no-template-curly-in-string */ +import type { Locale } from '../LocaleProvider'; +import DatePicker from '../DateTimePicker/DatePicker/Locale/hi_IN'; +import Dialog from '../Dialog/BaseDialog/Locale/hi_IN'; +import InfoBar from '../InfoBar/Locale/hi_IN'; +import Pagination from '../Pagination/Locale/hi_IN'; +import Panel from '../Panel/Locale/hi_IN'; +import Stepper from '../Stepper/Locale/hi_IN'; +import Table from '../Table/Locale/hi_IN'; +import TimePicker from '../DateTimePicker/TimePicker/Locale/hi_IN'; +import Upload from '../Upload/Locale/hi_IN'; + +const typeTemplate = '${label} कोई मान्य ${type} नहीं है'; + +const localeValues: Locale = { + locale: 'hi', + global: { + placeholder: 'चुनना', + }, + DatePicker, + Dialog, + Form: { + optional: '(वैकल्पिक)', + defaultValidateMessages: { + default: '${label} के लिए फ़ील्ड सत्यापन त्रुटि', + required: '${label} आवश्यक है', + enum: '${label} [${enum}] में से एक होना चाहिए', + whitespace: '${label} एक रिक्त वर्ण नहीं हो सकता', + date: { + format: '${label} दिनांक स्वरूप अमान्य है', + parse: '${label} को दिनांक में कनवर्ट नहीं किया जा सकता', + invalid: '${label} एक अमान्य दिनांक है', + }, + types: { + string: typeTemplate, + method: typeTemplate, + array: typeTemplate, + object: typeTemplate, + number: typeTemplate, + date: typeTemplate, + boolean: typeTemplate, + integer: typeTemplate, + float: typeTemplate, + regexp: typeTemplate, + email: typeTemplate, + url: typeTemplate, + hex: typeTemplate, + }, + string: { + len: '${label} ${len} वर्णों का होना चाहिए', + min: '${label} कम से कम ${min} वर्णों का होना चाहिए', + max: '${label} ${max} वर्णों तक होना चाहिए', + range: '${label} ${min}-${max} वर्णों के बीच होना चाहिए', + }, + number: { + len: '${label} ${len} के बराबर होना चाहिए', + min: '${label} न्यूनतम ${min} होना चाहिए', + max: '${label} अधिकतम ${max} होना चाहिए', + range: '${label} ${min}-${max} के बीच होना चाहिए', + }, + array: { + len: '${len} ${label} होना चाहिए', + min: 'कम से कम ${min} ${label}', + max: 'अधिकतम ${max} ${label}', + range: '${label} की मात्रा ${min}-${max} के बीच होनी चाहिए', + }, + pattern: { + mismatch: '${label} पैटर्न ${pattern} से मेल नहीं खाता है', + }, + }, + }, + InfoBar, + Pagination, + Panel, + Stepper, + Table, + TimePicker, + Upload, +}; + +export default localeValues; diff --git a/src/components/LocaleProvider/Tests/__snapshots__/index.test.js.snap b/src/components/LocaleProvider/Tests/__snapshots__/index.test.js.snap index fc756a2f9..d5fe74820 100644 --- a/src/components/LocaleProvider/Tests/__snapshots__/index.test.js.snap +++ b/src/components/LocaleProvider/Tests/__snapshots__/index.test.js.snap @@ -180,6 +180,16 @@ LoadedCheerio { } `; +exports[`Locale Provider should display the text as hi 1`] = ` +LoadedCheerio { + "length": 0, + "options": Object { + "decodeEntities": true, + "xml": false, + }, +} +`; + exports[`Locale Provider should display the text as hr 1`] = ` LoadedCheerio { "length": 0, diff --git a/src/components/LocaleProvider/Tests/index.test.js b/src/components/LocaleProvider/Tests/index.test.js index d6511cb4b..506ac27ca 100644 --- a/src/components/LocaleProvider/Tests/index.test.js +++ b/src/components/LocaleProvider/Tests/index.test.js @@ -26,6 +26,7 @@ import frBE from '../fr_BE'; import frCA from '../fr_CA'; import frFR from '../fr_FR'; import heIL from '../he_IL'; +import hiIN from '../hi_IN'; import hrHR from '../hr_HR'; import htHT from '../ht_HT'; import huHU from '../hu_HU'; @@ -66,6 +67,7 @@ const locales = [ frCA, frFR, heIL, + hiIN, hrHR, htHT, huHU, diff --git a/src/components/LocaleProvider/hi_IN.tsx b/src/components/LocaleProvider/hi_IN.tsx new file mode 100644 index 000000000..486a93ea1 --- /dev/null +++ b/src/components/LocaleProvider/hi_IN.tsx @@ -0,0 +1,3 @@ +import locale from '../Locale/hi_IN'; + +export default locale; diff --git a/src/components/Pagination/Locale/hi_IN.tsx b/src/components/Pagination/Locale/hi_IN.tsx new file mode 100644 index 000000000..e9ac8ae05 --- /dev/null +++ b/src/components/Pagination/Locale/hi_IN.tsx @@ -0,0 +1,18 @@ +import type { PaginationLocale } from '../Pagination.types'; + +const locale: PaginationLocale = { + lang: { + locale: 'hi_IN', + goToText: 'यहाँ जाओ', + nextIconButtonAriaLabel: 'अगला', + pagerText: 'का', + pageSizeButtonAriaLabel: 'चयनित पृष्ठ का आकार', + pageSizeText: 'पृष्ठ', + previousIconButtonAriaLabel: 'पिछला', + quickNextIconButtonAriaLabel: 'अगले 5', + quickPreviousIconButtonAriaLabel: 'पिछले 5', + totalText: 'कुल', + }, +}; + +export default locale; diff --git a/src/components/Panel/Locale/hi_IN.tsx b/src/components/Panel/Locale/hi_IN.tsx new file mode 100644 index 000000000..279a89319 --- /dev/null +++ b/src/components/Panel/Locale/hi_IN.tsx @@ -0,0 +1,10 @@ +import type { PanelLocale } from '../Panel.types'; + +const locale: PanelLocale = { + lang: { + locale: 'hi_IN', + closeButtonAriaLabelText: 'बंद करना', + }, +}; + +export default locale; diff --git a/src/components/Stepper/Locale/hi_IN.tsx b/src/components/Stepper/Locale/hi_IN.tsx new file mode 100644 index 000000000..5acee5cb8 --- /dev/null +++ b/src/components/Stepper/Locale/hi_IN.tsx @@ -0,0 +1,15 @@ +import type { StepperLocale } from '../Stepper.types'; + +const locale: StepperLocale = { + lang: { + locale: 'hi_IN', + completeAriaLabelText: 'पूरा', + nodeAriaLabelText: 'गांठ', + scrollDownAriaLabelText: 'नीचे स्क्रॉल करें', + scrollLeftAriaLabelText: 'बाईं ओर स्क्रॉल करें', + scrollRightAriaLabelText: 'दाईं ओर स्क्रॉल करें', + scrollUpAriaLabelText: 'ऊपर स्क्रॉल करें', + }, +}; + +export default locale; diff --git a/src/components/Table/Locale/hi_IN.tsx b/src/components/Table/Locale/hi_IN.tsx new file mode 100644 index 000000000..db1c97bca --- /dev/null +++ b/src/components/Table/Locale/hi_IN.tsx @@ -0,0 +1,25 @@ +import type { TableLocale } from '../Table.types'; + +const locale: TableLocale = { + lang: { + locale: 'hi_IN', + filterConfirmText: 'ठीक है', + filterResetText: 'रीसेट', + filterEmptyText: 'कोई फ़िल्टर नहीं', + filterCheckallText: 'सभी आइटम्स का चयन करें', + filterSearchPlaceholderText: 'फ़िल्टर में खोजें', + emptyText: 'कोई डेटा नहीं मिला', + selectInvertText: 'इनवर्ट वर्तमान पृष्ठ', + selectNoneText: 'सभी डेटा साफ़ करें', + selectionAllText: 'सभी डेटा का चयन करें', + expandText: 'विस्तृत पंक्ति', + collapseText: 'पतन विवाद', + triggerDescText: 'अवरोही क्रमबद्ध करने के लिए क्लिक करें', + triggerAscText: 'आरोही क्रमबद्ध करने के लिए क्लिक करें', + cancelSortText: 'सॉर्टिंग रद्द करने के लिए क्लिक करें', + scrollLeftAriaLabelText: 'बाईं ओर स्क्रॉल करें', + scrollRightAriaLabelText: 'दाईं ओर स्क्रॉल करें', + }, +}; + +export default locale; diff --git a/src/components/Upload/Locale/hi_IN.tsx b/src/components/Upload/Locale/hi_IN.tsx new file mode 100644 index 000000000..64cba94a4 --- /dev/null +++ b/src/components/Upload/Locale/hi_IN.tsx @@ -0,0 +1,28 @@ +import type { UploadLocale } from '../Upload.types'; + +const locale: UploadLocale = { + lang: { + locale: 'hi_IN', + acceptedFileTypesText: '(doc, docx, pdf या txt)', + downloadFileText: 'फ़ाइल डाउनलोड करें', + dragAndDropFileText: 'फ़ाइल खींचें और छोड़ें', + dragAndDropMultipleFilesText: 'फ़ाइलें खींचें और छोड़ें', + modalCancelText: 'रद्द करना', + modalCloseButtonAriaLabelText: 'बंद करना', + modalOkText: 'ठीक है', + modalTitleText: 'छवि संपादित करें', + previewFileText: 'फ़ाइल का पूर्वावलोकन करें', + removeFileText: 'फ़ाइल निकालें', + replaceFileText: 'बदलें', + rotateLeftButtonAriaLabelText: 'बाएँ घुमाएं', + rotateRightButtonAriaLabelText: 'दाईं ओर घुमाएं', + selectFileText: 'फ़ाइल का चयन करें', + selectMultipleFilesText: 'फ़ाइलों का चयन करें', + uploadErrorText: 'फ़ाइल अपलोड विफल', + uploadingText: 'अपलोड', + zoomInButtonAriaLabelText: 'ज़ूम इन', + zoomOutButtonAriaLabelText: 'ज़ूम आउट', + }, +}; + +export default locale;