Material-components-android: [MaterialDatePicker] Partial localization.

Created on 14 Nov 2019  ·  6Comments  ·  Source: material-components/material-components-android

Description: There are no methods for modifying hints, input errors and header selection text. By default, if any language other than English is selected on the device, the text on the dialog is only partially translated (In my case part of the text in English and part in Russian). I was helped by redefinition of resources, but this is a temporary solution and I do not think that it should be so

Expected behavior:
It is expected that there will be a translation into the local language of the device.
Снимок экрана 2019-11-14 в 01 47 04
Снимок экрана 2019-11-14 в 01 48 29

Source code: example app https://github.com/viktkurl/MaterialLibIssue

Android API version: 28

Material Library version: 1.2.0-alpha01

Device: emulator Pixel 2 XL

bug

Most helpful comment

If it helps anyone, here are the resources I've redefined:

<string name="mtrl_picker_range_header_unselected" tools:override="true">Выберите дату</string>

<string name="mtrl_picker_range_header_only_start_selected" tools:override="true">%s - Дата окончания</string>

<string name="mtrl_picker_range_header_only_end_selected" tools:override="true">Дата начала - %s</string>

<string name="mtrl_picker_text_input_date_range_start_hint" tools:override="true">Дата начала</string>

<string name="mtrl_picker_text_input_date_range_end_hint" tools:override="true">Дата начала</string>

<string name="mtrl_picker_text_input_date_format" tools:override="true">dd.MM.yyyy</string>

<string name="mtrl_picker_out_of_range" tools:override="true">Вы вышли за границу\nдопустимых значений: %1$s</string>

<string name="mtrl_picker_invalid_format" tools:override="true">Неверный формат даты.\Используйте: %1$s</string>

<string name="mtrl_picker_save" tools:override="true">Сохранить</string>

All 6 comments

If it helps anyone, here are the resources I've redefined:

<string name="mtrl_picker_range_header_unselected" tools:override="true">Выберите дату</string>

<string name="mtrl_picker_range_header_only_start_selected" tools:override="true">%s - Дата окончания</string>

<string name="mtrl_picker_range_header_only_end_selected" tools:override="true">Дата начала - %s</string>

<string name="mtrl_picker_text_input_date_range_start_hint" tools:override="true">Дата начала</string>

<string name="mtrl_picker_text_input_date_range_end_hint" tools:override="true">Дата начала</string>

<string name="mtrl_picker_text_input_date_format" tools:override="true">dd.MM.yyyy</string>

<string name="mtrl_picker_out_of_range" tools:override="true">Вы вышли за границу\nдопустимых значений: %1$s</string>

<string name="mtrl_picker_invalid_format" tools:override="true">Неверный формат даты.\Используйте: %1$s</string>

<string name="mtrl_picker_save" tools:override="true">Сохранить</string>

This is not Russian confined. The translations are missing for all other countries too as you can see here:
https://github.com/material-components/material-components-android/tree/c097d3d33506be7382d3bda20909d5f08bb1f220/lib/java/com/google/android/material/datepicker/res
there are no values-XX language resource folder with strings inside

This is not Russian confined. The translations are missing for all other countries too as you can see here:
https://github.com/material-components/material-components-android/tree/c097d3d33506be7382d3bda20909d5f08bb1f220/lib/java/com/google/android/material/datepicker/res
there are no values-XX language resource folder with strings inside

Yes, I wrote about it being for any language in description. But for positive, negative and calendar weekdays uses resources from @android:string and translated normally :)

Can confirm, no Czech translations in 1.2.0-alpha05.

@viktkurl, thanks, but it is only for date range. For single date replace strings found here.

Will add more lines.

<string name="mtrl_picker_date_header_title" tools:override="true">Выберите дату</string>
<string name="mtrl_picker_date_header_unselected" tools:override="true">Выбранная дата</string>
<string name="mtrl_picker_text_input_date_hint" tools:override="true">Дата</string>
<string name="mtrl_picker_text_input_year_abbr" tools:override="true">г</string>
<string name="mtrl_picker_text_input_month_abbr" tools:override="true">м</string>
<string name="mtrl_picker_text_input_day_abbr" tools:override="true">д</string>
<string name="mtrl_picker_invalid_range" tools:override="true">Неверный диапазон.</string>
<string name="mtrl_picker_invalid_format_use" tools:override="true">Формат: %1$s</string>
<string name="mtrl_picker_invalid_format_example" tools:override="true">Пример: %1$s</string>

So when will you add the translations for other languages? I assume Google can hire some translators?

Was this page helpful?
0 / 5 - 0 ratings