Skip to content

Multi-locale Ivy builds do not use registerLocaleData #15974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
filipesilva opened this issue Oct 29, 2019 · 3 comments
Closed

Multi-locale Ivy builds do not use registerLocaleData #15974

filipesilva opened this issue Oct 29, 2019 · 3 comments

Comments

@filipesilva
Copy link
Contributor

localeData, obtained via @angular/common/locales/<locale>, is needed for several FW features like pluralization.

In VE each build resulted in a single locale. To register the locale data in VE the CLI added the following code via a transform:

import { registerLocaleData } from '@angular/common';
import localeFr from '@angular/common/locales/fr';
registerLocaleData(localeFr, 'fr');

Locales can also have extra information that the CLI did not handle. It would have required to use add the code below instead:

import { registerLocaleData } from '@angular/common';
import localeFr from '@angular/common/locales/fr';
import localeFrExtra from '@angular/common/locales/extra/fr';
registerLocaleData(localeFr, 'fr-FR', localeFrExtra);

In Ivy each build can result in several locales. To use a similar mechanism would look like this:

import {registerLocaleData} from '@angular/common';
import localeFr from '@angular/common/locales/fr';
import localeDe from '@angular/common/locales/de';
switch ($localize.locale) {
  case 'fr':
    registerLocaleData(localeFr);
    break;
  case 'de':    
    registerLocaleData(localeDe);
  default:
    break;
}

This approach is not ideal because all locale-specific builds would include all locale data.

Since localize operates after code is built and bundled, introducing locale specific data presents a novel problem.

A repro of this problem can be found in https://github.com/filipesilva/i18n. It is still possible to do individual locale builds (via the i18n* options) with Ivy though.

@ngbot ngbot bot modified the milestone: Backlog Oct 29, 2019
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2019
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2019
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2019
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2019
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2019
clydin pushed a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2019
clydin pushed a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2019
clydin pushed a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2019
clydin pushed a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2019
clydin pushed a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2019
vikerman pushed a commit that referenced this issue Oct 30, 2019
@filipesilva
Copy link
Contributor Author

@vikerman this is still open. The PR was related to this issue but does not fix it.

@filipesilva filipesilva reopened this Oct 30, 2019
@clydin
Copy link
Member

clydin commented Nov 25, 2019

This has since been fixed via #15989 & #16196

@clydin clydin closed this as completed Nov 25, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants