微信小程序-国际化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)]);

新版已解决此问题

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