使用 copy-webpack-plugin,我在構建代碼時將 [contenthash] 添加到我的 i18next 翻譯檔案的名稱中。
{
from: 'public/locales/',
to: 'locales/[path][name].[contenthash][ext]',
},
在輸出中,我得到一個具有該名稱翻譯的檔案。[內容哈希] .json
當然,當我嘗試在服務器上執行代碼時,我得到一個錯誤,因為 i18next 正在尋找名為 translation.json 的檔案。
問題是,我可以在 loadPath 屬性的 i18next 的 backendOptions 中以某種方式獲取 [contenthash] 嗎?
我知道 loadPath 也可以是一個函式,但不幸的是只有 lang 和 path 出現在那里,我自己無法生成哈希。
uj5u.com熱心網友回復:
使用i18next-http-backend的 loadPath 選項也可以是一個函式。這樣您就可以構建您的自定義路徑:https ://github.com/i18next/i18next-http-backend/issues/86
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/496210.html
