@sap-ux/i18n
Version:
Library for i18n
35 lines • 1.06 kB
JavaScript
import { parseProperties } from '../../parser/properties/parser/index.js';
import { getAnnotation } from './annotation.js';
/**
* Convert `.properties` content to i18n entries.
*
* @param content `.properties` content
* @param filePath path to i18n file
* @returns i18n entry
*/
export function propertiesToI18nEntry(content, filePath = '') {
const i18nEntries = [];
const { ast } = parseProperties(content);
for (let i = 0; ast.length > i; i++) {
const line = ast[i];
if (line.type !== 'key-element-line') {
continue;
}
const commentLine = ast[i - 1];
const entry = {
filePath,
key: {
value: line.key.value,
range: line.key.range
},
value: {
value: line.element.value,
range: line.element.range
},
annotation: getAnnotation(commentLine)
};
i18nEntries.push(entry);
}
return i18nEntries;
}
//# sourceMappingURL=properties.js.map