簡體   English   中英

在Ember CLI構建期間合並插件供應商文件

[英]Combine Addon Vendor Files During Ember CLI Build

假設我有三個自定義的Ember插件...

addon-a
addon-b
addon-c

我希望每個插件都包含其自己的vendor / translations /文件夾,其中包含針對每個區域設置的不同JSON文件。

addon-a
  vendor
    translations
      en.json
      es.json
      ...
addon-b
  vendor
    translations
      en.json
      es.json
      ...
addon-c
  vendor
    translations
      en.json
      es.json
      ...

我想在我的主要Ember.js應用程序( my-app )中包括這三個插件。 在構建過程中,我想為每個語言環境創建一個JSON文件,其中包含所有三個插件的內容。

// my-app's final en.json file.
{
    "addon-a": {
        // addon-a en.json contents output here.
    },
    "addon-b": {
        // addon-b en.json contents output here.
    },
    "addon-c": {
        // addon-c en.json contents output here.
    }
}

我正在使用app.import( 'vendor / translations / en.json'將插件的JSON文件包含到my-app的生成輸出中。 但是,我堅持嘗試為每個語言環境創建單個JSON文件。 然后,我想刪除導入來創建級聯文件的插件的JSON文件。

我想做的事可能嗎? 如果是這樣,任何人都可以提供有關如何實現這一目標的步驟,或者向我指出類似的例子嗎? 謝謝!

經過一番思考,我相信最好的方法是通過在Ember應用程序中創建自定義的Broccoli插件。 該插件將遍歷所有插件,並在構建時將所有翻譯匯總到聯合文件中。

該答案基於ember-intl的TranslationReducer Broccoli插件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM