Files
vscode-front-matter/src/utils/getLocalizationFile.ts
2023-08-30 15:51:05 +02:00

19 lines
627 B
TypeScript

import { Uri, l10n } from 'vscode';
import { Extension, Logger, parseWinPath } from '../helpers';
import { readFileAsync } from './readFileAsync';
import { join } from 'path';
export const getLocalizationFile = async () => {
try {
const localeFilePath =
l10n.uri?.fsPath ||
Uri.file(join(parseWinPath(Extension.getInstance().extensionPath.fsPath), `/l10n/bundle.l10n.json`)).fsPath;
const fileContents = await readFileAsync(localeFilePath, 'utf-8');
return fileContents;
} catch (error) {
Logger.error(`Failed to get the localization file: ${(error as Error).message}`);
return '';
}
};