Possible to pass Variable to angular.json and avoid code duplication?












-1














I am looking for a way to pass information to angular.json file so that I do not need to repeat build configurations and avoid all the code duplication. I can not explain well so I'll try with an example. So In my angular.jsonunder configurations I have something like



"configurations": {
"de": {
"aot": true,
"i18nLocale": "de",
"i18nFile": "project/src/locale/messages.de.xlf",
"i18nFormat": "xlf"
},
"en-gb": {
"aot": true,
"i18nLocale": "en-gb",
"i18nFile": "project/src/locale/messages.en-gb.xlf",
"i18nFormat": "xlf"
},
"en-us": {
"aot": true,
"i18nLocale": "en-us",
"i18nFile": "project/src/locale/messages.en-us.xlf",
"i18nFormat": "xlf"
},
"es": {
"aot": true,
"i18nLocale": "es",
"i18nFile": "project/src/locale/messages.es.xlf",
"i18nFormat": "xlf"
},
"fr": {
"aot": true,
"i18nLocale": "fr",
"i18nFile": "project/src/locale/messages.fr.xlf",
"i18nFormat": "xlf"
},
"it": {
"aot": true,
"i18nLocale": "it",
"i18nFile": "project/src/locale/messages.it.xlf",
"i18nFormat": "xlf"
},
"pt-br": {
"aot": true,
"i18nLocale": "pt-br",
"i18nFile": "project/src/locale/messages.pt-br.xlf",
"i18nFormat": "xlf"
}


Is there a way to have a variable like lets say i18n and I can use it in angular.json like $i18n :



"configurations": {
"i18n": {
"aot": true,
"i18nLocale": "$i18n",
"i18nFile": "project/src/locale/messages.$i18n.xlf",
"i18nFormat": "xlf"
}


I am not good with english. I hope I explained well using the example for what I am looking for. Thanks in advance.










share|improve this question




















  • 1




    Unfortunately, you can't have this. See stackoverflow.com/questions/23869882/…
    – AkshayM
    Nov 12 '18 at 13:27






  • 1




    this makes me so sad, thanks for the reply!
    – Tanzeel
    Nov 12 '18 at 13:48


















-1














I am looking for a way to pass information to angular.json file so that I do not need to repeat build configurations and avoid all the code duplication. I can not explain well so I'll try with an example. So In my angular.jsonunder configurations I have something like



"configurations": {
"de": {
"aot": true,
"i18nLocale": "de",
"i18nFile": "project/src/locale/messages.de.xlf",
"i18nFormat": "xlf"
},
"en-gb": {
"aot": true,
"i18nLocale": "en-gb",
"i18nFile": "project/src/locale/messages.en-gb.xlf",
"i18nFormat": "xlf"
},
"en-us": {
"aot": true,
"i18nLocale": "en-us",
"i18nFile": "project/src/locale/messages.en-us.xlf",
"i18nFormat": "xlf"
},
"es": {
"aot": true,
"i18nLocale": "es",
"i18nFile": "project/src/locale/messages.es.xlf",
"i18nFormat": "xlf"
},
"fr": {
"aot": true,
"i18nLocale": "fr",
"i18nFile": "project/src/locale/messages.fr.xlf",
"i18nFormat": "xlf"
},
"it": {
"aot": true,
"i18nLocale": "it",
"i18nFile": "project/src/locale/messages.it.xlf",
"i18nFormat": "xlf"
},
"pt-br": {
"aot": true,
"i18nLocale": "pt-br",
"i18nFile": "project/src/locale/messages.pt-br.xlf",
"i18nFormat": "xlf"
}


Is there a way to have a variable like lets say i18n and I can use it in angular.json like $i18n :



"configurations": {
"i18n": {
"aot": true,
"i18nLocale": "$i18n",
"i18nFile": "project/src/locale/messages.$i18n.xlf",
"i18nFormat": "xlf"
}


I am not good with english. I hope I explained well using the example for what I am looking for. Thanks in advance.










share|improve this question




















  • 1




    Unfortunately, you can't have this. See stackoverflow.com/questions/23869882/…
    – AkshayM
    Nov 12 '18 at 13:27






  • 1




    this makes me so sad, thanks for the reply!
    – Tanzeel
    Nov 12 '18 at 13:48
















-1












-1








-1







I am looking for a way to pass information to angular.json file so that I do not need to repeat build configurations and avoid all the code duplication. I can not explain well so I'll try with an example. So In my angular.jsonunder configurations I have something like



"configurations": {
"de": {
"aot": true,
"i18nLocale": "de",
"i18nFile": "project/src/locale/messages.de.xlf",
"i18nFormat": "xlf"
},
"en-gb": {
"aot": true,
"i18nLocale": "en-gb",
"i18nFile": "project/src/locale/messages.en-gb.xlf",
"i18nFormat": "xlf"
},
"en-us": {
"aot": true,
"i18nLocale": "en-us",
"i18nFile": "project/src/locale/messages.en-us.xlf",
"i18nFormat": "xlf"
},
"es": {
"aot": true,
"i18nLocale": "es",
"i18nFile": "project/src/locale/messages.es.xlf",
"i18nFormat": "xlf"
},
"fr": {
"aot": true,
"i18nLocale": "fr",
"i18nFile": "project/src/locale/messages.fr.xlf",
"i18nFormat": "xlf"
},
"it": {
"aot": true,
"i18nLocale": "it",
"i18nFile": "project/src/locale/messages.it.xlf",
"i18nFormat": "xlf"
},
"pt-br": {
"aot": true,
"i18nLocale": "pt-br",
"i18nFile": "project/src/locale/messages.pt-br.xlf",
"i18nFormat": "xlf"
}


Is there a way to have a variable like lets say i18n and I can use it in angular.json like $i18n :



"configurations": {
"i18n": {
"aot": true,
"i18nLocale": "$i18n",
"i18nFile": "project/src/locale/messages.$i18n.xlf",
"i18nFormat": "xlf"
}


I am not good with english. I hope I explained well using the example for what I am looking for. Thanks in advance.










share|improve this question















I am looking for a way to pass information to angular.json file so that I do not need to repeat build configurations and avoid all the code duplication. I can not explain well so I'll try with an example. So In my angular.jsonunder configurations I have something like



"configurations": {
"de": {
"aot": true,
"i18nLocale": "de",
"i18nFile": "project/src/locale/messages.de.xlf",
"i18nFormat": "xlf"
},
"en-gb": {
"aot": true,
"i18nLocale": "en-gb",
"i18nFile": "project/src/locale/messages.en-gb.xlf",
"i18nFormat": "xlf"
},
"en-us": {
"aot": true,
"i18nLocale": "en-us",
"i18nFile": "project/src/locale/messages.en-us.xlf",
"i18nFormat": "xlf"
},
"es": {
"aot": true,
"i18nLocale": "es",
"i18nFile": "project/src/locale/messages.es.xlf",
"i18nFormat": "xlf"
},
"fr": {
"aot": true,
"i18nLocale": "fr",
"i18nFile": "project/src/locale/messages.fr.xlf",
"i18nFormat": "xlf"
},
"it": {
"aot": true,
"i18nLocale": "it",
"i18nFile": "project/src/locale/messages.it.xlf",
"i18nFormat": "xlf"
},
"pt-br": {
"aot": true,
"i18nLocale": "pt-br",
"i18nFile": "project/src/locale/messages.pt-br.xlf",
"i18nFormat": "xlf"
}


Is there a way to have a variable like lets say i18n and I can use it in angular.json like $i18n :



"configurations": {
"i18n": {
"aot": true,
"i18nLocale": "$i18n",
"i18nFile": "project/src/locale/messages.$i18n.xlf",
"i18nFormat": "xlf"
}


I am not good with english. I hope I explained well using the example for what I am looking for. Thanks in advance.







json angular angular-cli






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 13:21









selem mn

4,85541939




4,85541939










asked Nov 12 '18 at 13:17









Tanzeel

195111




195111








  • 1




    Unfortunately, you can't have this. See stackoverflow.com/questions/23869882/…
    – AkshayM
    Nov 12 '18 at 13:27






  • 1




    this makes me so sad, thanks for the reply!
    – Tanzeel
    Nov 12 '18 at 13:48
















  • 1




    Unfortunately, you can't have this. See stackoverflow.com/questions/23869882/…
    – AkshayM
    Nov 12 '18 at 13:27






  • 1




    this makes me so sad, thanks for the reply!
    – Tanzeel
    Nov 12 '18 at 13:48










1




1




Unfortunately, you can't have this. See stackoverflow.com/questions/23869882/…
– AkshayM
Nov 12 '18 at 13:27




Unfortunately, you can't have this. See stackoverflow.com/questions/23869882/…
– AkshayM
Nov 12 '18 at 13:27




1




1




this makes me so sad, thanks for the reply!
– Tanzeel
Nov 12 '18 at 13:48






this makes me so sad, thanks for the reply!
– Tanzeel
Nov 12 '18 at 13:48














1 Answer
1






active

oldest

votes


















1














I don't speak angular, but in the hope this is useful, I think you're looking at this something like this:



echo '["de","en-gb","en-us","es","fr","it"]' | jq '
{"configuration":[ . as $c |
{
($c):{
"aot":true,
"i18nLocale": $c,
"i18nFile": ("project/src/locale/messages." + $c + ".xlf"),
"i18nFormat": "xlf"
}
}
]}'


This command uses jq command line parser to forge a JSON configuration according to your first example.



You can grow the table sent by echo to jq to any country string and get as many configurations.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263011%2fpossible-to-pass-variable-to-angular-json-and-avoid-code-duplication%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I don't speak angular, but in the hope this is useful, I think you're looking at this something like this:



    echo '["de","en-gb","en-us","es","fr","it"]' | jq '
    {"configuration":[ . as $c |
    {
    ($c):{
    "aot":true,
    "i18nLocale": $c,
    "i18nFile": ("project/src/locale/messages." + $c + ".xlf"),
    "i18nFormat": "xlf"
    }
    }
    ]}'


    This command uses jq command line parser to forge a JSON configuration according to your first example.



    You can grow the table sent by echo to jq to any country string and get as many configurations.






    share|improve this answer


























      1














      I don't speak angular, but in the hope this is useful, I think you're looking at this something like this:



      echo '["de","en-gb","en-us","es","fr","it"]' | jq '
      {"configuration":[ . as $c |
      {
      ($c):{
      "aot":true,
      "i18nLocale": $c,
      "i18nFile": ("project/src/locale/messages." + $c + ".xlf"),
      "i18nFormat": "xlf"
      }
      }
      ]}'


      This command uses jq command line parser to forge a JSON configuration according to your first example.



      You can grow the table sent by echo to jq to any country string and get as many configurations.






      share|improve this answer
























        1












        1








        1






        I don't speak angular, but in the hope this is useful, I think you're looking at this something like this:



        echo '["de","en-gb","en-us","es","fr","it"]' | jq '
        {"configuration":[ . as $c |
        {
        ($c):{
        "aot":true,
        "i18nLocale": $c,
        "i18nFile": ("project/src/locale/messages." + $c + ".xlf"),
        "i18nFormat": "xlf"
        }
        }
        ]}'


        This command uses jq command line parser to forge a JSON configuration according to your first example.



        You can grow the table sent by echo to jq to any country string and get as many configurations.






        share|improve this answer












        I don't speak angular, but in the hope this is useful, I think you're looking at this something like this:



        echo '["de","en-gb","en-us","es","fr","it"]' | jq '
        {"configuration":[ . as $c |
        {
        ($c):{
        "aot":true,
        "i18nLocale": $c,
        "i18nFile": ("project/src/locale/messages." + $c + ".xlf"),
        "i18nFormat": "xlf"
        }
        }
        ]}'


        This command uses jq command line parser to forge a JSON configuration according to your first example.



        You can grow the table sent by echo to jq to any country string and get as many configurations.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 '18 at 14:12









        oliv

        8,2911130




        8,2911130






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263011%2fpossible-to-pass-variable-to-angular-json-and-avoid-code-duplication%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma