使用微信小程序國際化解決方案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)]);
新版已解決此問題