微信小程序-國際化miniprogram-i18n問題

使用微信小程序國際化解決方案miniprogram-i18n時遇到的問題:

Windows下會導致合併後wxml報錯:找不到locales.wxs文件。

所以需要修改下面的文件:
在項目根目錄打開“node_modules\@miniprogram-i18n\gulp-i18n-wxml”文件夾,打開index.js文件,找到如下代碼:

var relativeWxsPath = path.relative(path.dirname(file.path), wxsPath);

在其後添加如下代碼並保存:

relativeWxsPath = relativeWxsPath.replace(/\\/g, '/');

修改後代碼如下:

var transformedContents = transfomer.transform(file.contents.toString('utf-8'));
var relativeWxsPath = path.relative(path.dirname(file.path), wxsPath);
relativeWxsPath = relativeWxsPath.replace(/\\/g, '/');
var wxsTag = getWxsTag(relativeWxsPath, wxsModuleName);
file.contents = Buffer.concat([Buffer.from(wxsTag), Buffer.from(transformedContents)]);

新版已解決此問題

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章