This looks like a regression to me in v9:
I couldn't find a way to tell the cli the default locale to inject in my app instead of the default en-US. The only method I found is using the localize flag, but enabling it changes the way the app is built and slows the process with the extra _Generating localized bundles_ phase.
Shouldn't it inject the sourceLocale defined in the angular.json the way the --i18nLocale flag used to worked in pre v9 versions?
Hi @javiermarinros, can you give some more details on what you're trying to do?
Are you trying to make users visiting your site use a different locale by default? Are you trying to make local builds use a different locale by default? Are you trying to change the default value of LOCALE_ID injected into your app?
Hi @dgp1130, I would like to configure the default app locale (that is hardcoded to en-US) without using the localize flag (that adds extra overhead during builds with the _Generating localized bundles_ phase)
I think this could be better explained with an example: Using this angular.json should create builds injecting the es locale instead of en-US:
"projects": {
"projectName": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"i18n": {
**"sourceLocale": "es"**
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
**"localize": false,**
...
Ok, I think I'm understanding now. This was more of a historical limitation in View Engine when we didn't track sourceLocale as a separate locale, so we always used en-US. Currently there is no way to set the default to another locale without using --localize. The closest you can get is:
"projects": {
"my-project": {
// ...
"i18n": {
"sourceLocale": "es",
"locales": {
// ...
}
},
"architect": {
"build": {
"options": {
// ...
"localize": [ "es" ]
}
}
}
}
}
Then ng serve would serve This would localize only to the Spanish language in default builds, though it still has the overhead costs you mentioned (but only for one language).
As a feature request this is pretty reasonable. It makes sense that the sourceLocale should be the default when --localize=false. To make this happen, when --localize=false, we'll need to:
sourceLocale.LOCALE_ID to the sourceLocale value, so modules which inject it are accurate.Neither of these take too long in the build process, so they should not impact build times too much. The slow part is dealing with translations, which we don't have to do here because we are using the sourceLocale. Once that happens, ng serve and ng build should use sourceLocale throughout the app by default.
Most helpful comment
Ok, I think I'm understanding now. This was more of a historical limitation in View Engine when we didn't track
sourceLocaleas a separate locale, so we always useden-US. Currently there is no way to set the default to another locale without using--localize. The closest you can get is:Then
ng servewould serve This would localize only to the Spanish language in default builds, though it still has the overhead costs you mentioned (but only for one language).As a feature request this is pretty reasonable. It makes sense that the
sourceLocaleshould be the default when--localize=false. To make this happen, when--localize=false, we'll need to:sourceLocale.LOCALE_IDto thesourceLocalevalue, so modules which inject it are accurate.Neither of these take too long in the build process, so they should not impact build times too much. The slow part is dealing with translations, which we don't have to do here because we are using the
sourceLocale. Once that happens,ng serveandng buildshould usesourceLocalethroughout the app by default.