Skip to content

DateAdapter.setLocale defaults to certain languages #22411

Open
@hafidk

Description

@hafidk

Bug Report

I'm hitting my head against a wall here, thing is I've been using dateAdapter.setLocale to change the language of the mat-datepicker on the construction, it works so far for all the languages I've tried except two: Basque and Galician. According to the angular docs, these two locales are already integrated so it shouldn't be a problem, but when I try to set the locale for these it defaults the to Catalan all the text in the datepicker (specifically the months), I've tested different langs and these are the only ones where I have issues.

Demo and steps to reproduce the issue

Just use the setLocale function from the dateAdapter and try to set the Basque ("eu") or Galician ("gl") locales, it will default to Catalan ("ca").

Detailed Reproduction Steps

constructor(private dateAdapter: DateAdapter<NativeDateAdapter>, private translate: TranslateService) { 
  this.dateAdapter.setLocale(this.translate.currentLang); 
}

Explain the expected behavior

The translated text should appear on the specified lang.

Explain the current behavior

The translated text defaults to catalan when using those two langs, moreover, the setter works as it should be (after setLocale, the dateAdapter object has the lang property correctly)

Discuss the use-case or motivation for changing the existing behavior

List the affected versions of AngularJS, Material, OS, and browsers

@angular/cdk 11.2.4
@angular/cli 11.2.6
@angular/material 10.2.7
@schematics/angular 11.2.6
@schematics/update 0.1102.6
rxjs 6.6.3
typescript 4.1.5

Add anything else we should know

I've already tried to set them according to the language codes, such as:

this.dateAdapter.setLocale("eu");
this.dateAdapter.setLocale("eu-ES");
this.dateAdapter.setLocale("EU");

But to no avail.

Stack Trace

Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/datepickerneeds investigationA member of the team needs to do further investigation to determine the root cause

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions