Skip to content

Commit

Permalink
[MaterialDatePicker] Fix hint for Korean
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 520025180
  • Loading branch information
paulfthomas authored and pekingme committed Mar 28, 2023
1 parent dfbf4d9 commit bcc97bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/java/com/google/android/material/datepicker/UtcDates.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ static String getDefaultTextInputHint(Resources res, SimpleDateFormat format) {
formatHint = formatHint.replace("y", "yyyy");
}

// Remove duplicate year characters for Korean.
if (Locale.getDefault().getLanguage().equals(Locale.KOREAN.getLanguage())) {
formatHint = formatHint.replaceAll("y+", "y");
}

return formatHint.replace("d", dayChar).replace("M", monthChar).replace("y", yearChar);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,13 @@ public void textInputHintWith1CharYearLocalized() {

assertEquals("m/j/aaaa", hint);
}

@Test
@Config(qualifiers = "ko")
public void textInputHintForKorean() {
SimpleDateFormat sdf = new SimpleDateFormat("yy.M.d.");
String hint = UtcDates.getDefaultTextInputHint(context.getResources(), sdf);

assertEquals("년.월.일.", hint);
}
}

0 comments on commit bcc97bf

Please sign in to comment.