javascript - Migration to the angular v9. i18n breaking changes - Stack Overflow

I'm migrating an Angular project from 8.2.14 to the 9.0.0-rc.14. Using i18n for localization.I fol

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 .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?

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?

Share edited Feb 6, 2020 at 10:53 qiAlex asked Feb 6, 2020 at 10:39 qiAlexqiAlex 4,3562 gold badges21 silver badges35 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

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"
            }
        },
...

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.

Exactly, as @Markus said:

Your original language (developer) must not appear in '"locales": '.

Only in '"sourceLocale": '.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744885331a4599083.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信