Reputation: 4346
I'm migrating an Angular project from 8.2.14 to the 9.0.0-rc.14. Using i18n for localization.
I followed the guide here https://update.angular.io/#8.2:9.0 and it feels it went fine. After the upgrade, I'm trying to run the project, but
ng serve
leads to the following error:
An unhandled exception occurred: An i18n locale ('en-US') cannot both be a source locale and provide a translation.
See "...my local logs path...\angular-errors.log" for further details.
In the angular-errors.log
the error is more detailed:
[error] Error: An i18n locale ('en-US') cannot both be a source locale and provide a translation.
at createI18nOptions (...my project path...\node_modules\@angular-devkit\build-angular\src\utils\i18n-options.js:69:23)
at Object.configureI18nBuild (...my project path...\node_modules\@angular-devkit\build-angular\src\utils\i18n-options.js:100:18)
at process._tickCallback (internal/process/next_tick.js:68:7)
I have got more details about the error: opening the @angular-devkit\build-angular\src\utils\i18n-options.js:69:23
and I see the following logic:
if (locale === i18n.sourceLocale) {
throw new Error(`An i18n locale ('${locale}') cannot both be a source locale and provide a translation.`);
}
I have en-US
locale and I want to continue using it as both translation and source. So how to fix this breaking error?
Upvotes: 4
Views: 5188
Reputation: 395
Exactly, as @Markus said:
Your original language (developer) must not appear in '"locales": '.
Only in '"sourceLocale": '.
Upvotes: 0
Reputation: 1093
I assume your default language is different than English. Thus, you should have change the default source 'sourceLocale' as shown in the official docs.
So it would be like:
"projects": {
"AngularApp": {
"i18n": {
"sourceLocale": "he-IL",
"locales": {
"en-US": "src/locale/messages.en.xlf"
}
},
...
Upvotes: 4
Reputation: 81
simply open your angular.json file and remove the entry under locales which you have set under "sourceLocale". After the update locales only stores the translation not the language that you use in your source code.
Upvotes: 0