@sap-ux/i18n
Version:
Library for i18n
51 lines • 1.15 kB
JavaScript
import { stat } from 'node:fs';
import { getI18nConfiguration } from './config.js';
/**
* Get json path.
*
* @param path file path
* @returns .json file path
*/
export function jsonPath(path) {
return `${path}.json`;
}
/**
* Get properties path.
*
* @param path file path
* @param env cds environment
* @returns .properties file path
*/
export function capPropertiesPath(path, env) {
const { fallbackLanguage } = getI18nConfiguration(env);
const languageSuffix = fallbackLanguage === '' ? '' : `_${fallbackLanguage}`;
return `${path}${languageSuffix}.properties`;
}
/**
* Get csv path.
*
* @param path file path
* @returns .csv file path
*/
export function csvPath(path) {
return `${path}.csv`;
}
/**
* Check if a folder of a file exists.
*
* @param path an absolute path to a folder or a file
* @returns boolean
*/
export function doesExist(path) {
return new Promise((resolve) => {
stat(path, (err) => {
if (err) {
resolve(false);
}
else {
resolve(true);
}
});
});
}
//# sourceMappingURL=path.js.map