How to use assets from another locale in angular?
Asked Answered
A

1

8

I am using my application in three languages using @angular/localize and I am having trouble in the time take to deploy the server. The reason being that even though all locale use same assets, they are downloaded and they deployed for each one of them.

That's why I am trying to remove assets for all but one locale. And I did that using script and removing the folder itself. But now I want other locale to use the assets from en-US and not say 404 not found like they're doing right now.

Is there any way to achieve this currently?

My locale configuration is this:

"i18n": {
        "sourceLocale": "en-US",
        "locales": {
          "fr":  "src/locale/messages.fr.xtb",
          "pt": "src/locale/messages.pt.xtb",
          "hi": "src/locale/messages.hi.xtb",
        }
      },

And to check the serving I am using this configuration:

"prod-hi": {
                "fileReplacements": [
                    {
                      "replace": "src/environments/environment.ts",
                      "with": "src/environments/environment.prod.ts"
                    }
                  ],
                "optimization": true,
                "outputHashing": "all",
                "sourceMap": false,
                "extractCss": true,
                "namedChunks": false,
                "extractLicenses": true,
                "vendorChunk": false,
                "buildOptimizer": true,
                "deleteOutputPath": false,
                "assets": [],
                "localize": ["hi"]
              },
Acosta answered 31/7, 2020 at 14:33 Comment(1)
Great question! Have you found a solution to this?Mullock
B
1

in your 'local' configuation, you could use assets configuration to ignore/remove all assets for unwanted ones. and still outputing to asset folder:

"assets": [
 {
   "glob": "**/*",
   "input": "src/assets/",
   "ignore": [
      "**/hi/*",
      "**/en/*"
   ],
   "output": "/assets/"
 }
]

This has been taken from : https://angular.io/guide/workspace-config#assets-configuration

Brittnybritton answered 17/6, 2021 at 18:7 Comment(1)
This does not seems to work, at least not in Angular v18Carlina

© 2022 - 2024 — McMap. All rights reserved.