1 | import fs from 'node:fs';
|
2 | import path from 'node:path';
|
3 | import {DEFAULT_LANGUAGE} from './index.js';
|
4 |
|
5 | const getSystemLang = () => {
|
6 | let {locale} = new Intl.DateTimeFormat().resolvedOptions();
|
7 | try {
|
8 | locale = locale.slice(0, 2);
|
9 | } catch {
|
10 | console.info(`Couldn't get system language. Setting default: ${DEFAULT_LANGUAGE}`);
|
11 | locale = DEFAULT_LANGUAGE;
|
12 | }
|
13 |
|
14 | return locale;
|
15 | };
|
16 |
|
17 | const createFolders = fullPath => {
|
18 | const dir = path.dirname(fullPath);
|
19 | if (!fs.existsSync(dir)) {
|
20 | const result = fs.mkdirSync(dir, {recursive: true});
|
21 | console.log('Created output path:', result);
|
22 | }
|
23 | };
|
24 |
|
25 | export {getSystemLang, createFolders};
|