目录

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

新版已解决此问题