const str = '[zh-CN]中 文[en-EN]Engl ish[init-Lang]In it';
const nowLang = 'zh-CN';
const arr = str.match(/\[.+?\]/g)
let newMap = new Map();
const objData = {};
let beforeLang = null;
for(let i = 0; i < arr.length; i++){
const index = str.indexOf(arr[i]);
const langKey = arr[i].slice(1, -1);
const obj = {
start: index,
len: arr[i].length,
};
if(beforeLang){
const startIndex = newMap.get(beforeLang).start;
const len = newMap.get(beforeLang).len;
objData[beforeLang] = str.substring(startIndex + len, index)
}
if(i === arr.length - 1){
objData[langKey] = str.substring(index + arr[i].length);
}
newMap.set(langKey, obj);
beforeLang = langKey;
}
console.log(objData);