GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Can't use translation file for en-US: "An i18n locale ('en-US') cannot both be a source locale and provide a translation" · Issue #18422 · angular/angular-cli

Can't use translation file for en-US: "An i18n locale ('en-US') cannot both be a source locale and provide a translation" #18422

New issue
Copy link
New issue
Copy link
Open
Open
Can't use translation file for en-US: "An i18n locale ('en-US') cannot both be a source locale and provide a translation"#18422
Copy link
Labels
area: @angular-devkit/build-angulardevkit/build-angular:i18n
Milestone
needsTriage

Description

@MartinJaskulla
MartinJaskulla
opened on Jul 31, 2020
Issue body actions

🐞 bug report

I can't use a translation file for en-US:

i18n": {
    "locales": {
      "en-US": {
        "baseHref": "delete/us/en_us",
        "translation": "messages.en-us.xlf"
      }
    }
}

Description

  • Our app is translated into 40+ languages
  • We want our translation department to be responsible for all strings
  • We want to ignore the strings our developers have written in the HTML files
  • Therefore we need one build per messages.xlf file and no build for the "sourceLocale"
  • At the moment we are forced to manually copy the strings from the messages.en-us.xlf file back into our HTML every time our translation department makes a change to en-US

Possible solutions:

  • Allow "translation" as a property of "sourceLocale"
"sourceLocale": {
  "code": "en-US",
  "translation": "messages.en-us.xlf"
}
  • Add option to prevent the build of the source locale

🔬 Minimal Reproduction

https://github.com/MartinJaskulla/angular-issue-38316

🔥 Exception or Error


An unhandled exception occurred: An i18n locale ('en-US') cannot both be a source locale and provide a translation.

🌍 Your Environment

Angular Version:


Angular CLI: 9.0.7
Node: 12.13.1
OS: darwin x64

Angular: 9.0.7
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.7
@angular-devkit/build-angular     0.900.7
@angular-devkit/build-optimizer   0.900.7
@angular-devkit/build-webpack     0.900.7
@angular-devkit/core              9.0.7
@angular-devkit/schematics        9.0.7
@angular/localize                 9.1.12
@ngtools/webpack                  9.0.7
@schematics/angular               9.0.7
@schematics/update                0.900.7
rxjs                              6.5.5
typescript                        3.7.5
webpack                           4.41.2

Anything else relevant?
I know that there are several workarounds. For example we could provide a non-existent source locale "sourceLocale": "aa-aa" and delete the build afterwards. However our app is very big and we want to save the build time.
Furthermore our actual setup is more complex than the example provided above. For example the translations for the same locale e.g. my-app.com/de/en-US and my-app.com/us/en-US can be different. It would be useful for angular.json to provide some sort of nesting of the locales.

Reacted by Guillaume, delrueba, PopePAF, dmrickey, Filip Šalda, Ben Sorohan, Aly Ahmed, Frank Mosca, multimike77, Andriy Doroshenko and 25 more
Reacted by Timur Mishagin
Reacted by Timur Mishagin and Tizian Roth

Activity

  1. alan-agius4
    transferred this issue fromangular/angularon Aug 1, 2020
  2. alan-agius4
    added
    area: @angular-devkit/build-angular
    devkit/build-angular:i18n
    on Aug 1, 2020
  3. ngbot
    added this to the needsTriage milestone on Aug 1, 2020
  4. doliG commented on Aug 11, 2020

    @doliG
    doliG
    on Aug 11, 2020
    More actions

    I have the same problem, and agree with the suggested solution

    Allow translation as a property of sourceLocale

    Reacted by Boyd and Camila E. Blanc Fick
  5. simonpeters commented on Dec 2, 2020

    @simonpeters
    simonpeters
    on Dec 2, 2020
    More actions

    Same issue here, we only have one language but would like to use i18n so we can use translation tools to have non developers change the strings we use.

    Reacted by Frank Mosca, Boyd, lammas, praxem, nelisbijl, Oleksii and Kyle Bradshaw
  6. praxem commented on Jan 29, 2021

    @praxem
    praxem
    on Jan 29, 2021
    More actions

    We have the same problem...

    It is strange to think that in a huge complex application the main source of the language will be in HTML ...

    Reacted by Frank Mosca, Camila E. Blanc Fick and Timur Mishagin
  7. nelisbijl commented on Feb 9, 2021

    @nelisbijl
    nelisbijl
    on Feb 9, 2021
    More actions

    Same issue here, we only have one language but would like to use i18n so we can use translation tools to have non developers change the strings we use.

    My workaround:
    Configure a fake sourceLocale in angular.json. I used zxx, which is actually a valid ISO639-2 code (https://www.loc.gov/standards/iso639-2/php/code_list.php)
    Only downside is a warning during ng extract-i18n:

    Warning: AngularCompilerPlugin: Unable to load the locale data file "@angular/common/locales/zxx", please check that "zxx" is a valid locale id.
    If needed, you can use "registerLocaleData" manually.

    That will possibly disappear when you choose a different valid locale code not used by your application

    Reacted by Guillaume
  8. doliG commented on Feb 9, 2021

    @doliG
    doliG
    on Feb 9, 2021
    More actions

    I use the same workaround as @nelisbijl with aa-AA as ISO code and it works.

    But this is not a correct solution, can maintainer have a look at this ticket and give us a status ?

    poke @alan-agius4 @clydin @filipesilva @hansl and so on...

    Reacted by Stefan Schweiger, praxem, Timur Mishagin and Tim Gatzemeier
  9. stefan-schweiger commented on Apr 21, 2021

    @stefan-schweiger
    stefan-schweiger
    on Apr 21, 2021
    More actions

    Any potential update on this issue? It's really annoying to manage all your text with a service like lokalise.com when you can't have the source locale as a translation target.

    Reacted by praxem and Timur Mishagin
  10. clydin commented on Apr 21, 2021

    @clydin
    clydin
    on Apr 21, 2021
    Member
    More actions

    Private use subtags can be used to describe the unique nature of the source locale in these type of cases. For example, the following configuration section provides for a translated de locale while also describing the content within the source code as untranslated.

    “i18n”: {
    	“sourceLocale”: “de-x-source”,
    	“locales”: {
    		“de”: “./locales/de.xliff2”,
    		“en”: “./locales/en.xliff2”,
    		“fr”: “./locales/fr.xliff2”
    	}
    }
    
  11. stefan-schweiger commented on Apr 22, 2021

    @stefan-schweiger
    stefan-schweiger
    on Apr 22, 2021
    More actions

    @clydin I needed to change a few things in my extraction and upload scripts but this works well. Thank you very much :)

  12. martijn19811 commented on Nov 14, 2021

    @martijn19811
    martijn19811
    on Nov 14, 2021
    More actions

    @clydin Hi, I'm having the same issue here. Would like to use a default translations file for my sourceLocale. Although Im not sure how.

          "i18n": {
            "sourceLocale": "nl-x-source",
            "locales": {
              "nl":  "src/locale/messages.nl.xlf"
            }
          }

    The build works and the NL language is being used, but it does not use the translation file. what am I missing here?

    Oh, and Im actually not using the --localize flag in the application. I just want the default build to have a few translations. That's it :). Thanks for your help in advance!

  13. MartinJaskulla
    changed the title [-]Can't user translation file for en-US: "An i18n locale ('en-US') cannot both be a source locale and provide a translation"[/-] [+]Can't use translation file for en-US: "An i18n locale ('en-US') cannot both be a source locale and provide a translation"[/+] on Feb 14, 2022
  14. t-mish commented on Jun 23, 2023

    @t-mish
    t-mish
    on Jun 23, 2023
    More actions

    Angular team please pay attention to it because it's seems not so hard to do but can make developers' life much easier.

    Reacted by Lars Rye Jeppesen, karta571110, Wim Holvoet, joostgaren123, Badr Eddine ATTALBI ALAMI and Tim Gatzemeier
  15. createdbyjurand commented on Jan 24, 2024

    @createdbyjurand
    createdbyjurand
    on Jan 24, 2024 · Hidden as outdated
    show commentMore actions
  16. doliG commented on Jan 25, 2024

    @doliG
    doliG
    on Jan 25, 2024 · Hidden as resolved
    show commentMore actions
  17. attalbialami commented on May 16, 2024

    @attalbialami
    attalbialami
    on May 16, 2024 · Hidden as spam
    show commentMore actions
  18. adi-wtag commented on Jul 29, 2024

    @adi-wtag
    adi-wtag
    on Jul 29, 2024 · Hidden as spam
    show commentMore actions
  19. ahimik commented on Aug 10, 2024

    @ahimik
    ahimik
    on Aug 10, 2024 · Hidden as spam
    show commentMore actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @angular-devkit/build-angulardevkit/build-angular:i18n

    Type

    No type

    Projects

    No projects

      Milestone

      • needsTriageNo due date

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.