Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use assets from another locale in angular?

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"]
              },
like image 321
Panda Avatar asked Jul 31 '20 14:07

Panda


1 Answers

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

like image 130
Minus Avatar answered Sep 27 '22 20:09

Minus