@awesome-fe/translate
Version:
Translation utils
30 lines • 963 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.originalIdTokenizer = void 0;
// 翻译原文 id
function originalIdTokenizer(eat, value, silent) {
var matches = /^ *{@originalId (.*?)}/.exec(value);
if (matches) {
try {
if (silent || !matches) {
// either we are not eating (silent) or the match failed
return !!matches;
}
return eat(matches[0])({
type: 'originalId',
value: matches[1],
});
}
catch (e) {
this.file.fail('Unmatched originalId tag: ' + e.message);
}
}
}
exports.originalIdTokenizer = originalIdTokenizer;
function locate(value, fromIndex) {
var pattern = / *{@originalId (.*?)}/;
pattern.lastIndex = fromIndex;
return value.search(pattern);
}
originalIdTokenizer.locator = locate;
//# sourceMappingURL=original-id-tokenizer.js.map