利用Custom Label可以很方便的实现中英文对照,但是有的时候会出现参数替换的情况,这种情况可以通过统一的标识符作为替换标记。其实salesforce提供了类似java的替换方法。
如样例代码,这种情况实在Custom Settings中使用的案例,createSuccessTip中存储的内容“恭喜你创建成功。个案编号:{0},个案主题:{1}”
//发送提示消息
String content = WechatSettingPublic__c.getValues('createSuccessTip').content__c;
String[] arguments = new String[]{casetemp.CaseNumber,casetemp.subject};
String formattedReplyMSG = String.format(content, arguments);
String msg = '{ "touser":"'+openid+'","msgtype":"text", "text": { "content":"'+formattedReplyMSG+'" } }';
system.debug('==msg===' + msg);
WeChatAdvancedUtil.sendCustomMessage(token,msg,false);
如果需要实现中英文对照的话,使用Custom Label。createSuccessTip内容:“恭喜你创建成功。个案编号:{0},个案主题:{1}”
String[] arguments = new String[]{casetemp.CaseNumber,casetemp.subject};
String formattedMSG = String.format(System.Label.createSuccessTip,arguments);