refactor(locales): use es module
This commit is contained in:
parent
74a05ec739
commit
5bd0228da2
|
@ -1,6 +1,6 @@
|
|||
const fs = require('fs');
|
||||
const yaml = require('js-yaml');
|
||||
const ts = require('typescript');
|
||||
import * as fs from 'node:fs';
|
||||
import * as yaml from 'js-yaml';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
function createMembers(record) {
|
||||
return Object.entries(record)
|
||||
|
@ -14,7 +14,7 @@ function createMembers(record) {
|
|||
));
|
||||
}
|
||||
|
||||
module.exports = function generateDTS() {
|
||||
export default function generateDTS() {
|
||||
const locale = yaml.load(fs.readFileSync(`${__dirname}/ja-JP.yml`, 'utf-8'));
|
||||
const members = createMembers(locale);
|
||||
const elements = [
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* Languages Loader
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const yaml = require('js-yaml');
|
||||
import * as fs from 'node:fs';
|
||||
import * as yaml from 'js-yaml';
|
||||
|
||||
const merge = (...args) => args.reduce((a, c) => ({
|
||||
...a,
|
||||
|
@ -53,7 +53,7 @@ const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g')
|
|||
|
||||
const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(`${__dirname}/${c}.yml`, 'utf-8'))) || {}, a), {});
|
||||
|
||||
module.exports = Object.entries(locales)
|
||||
export default Object.entries(locales)
|
||||
.reduce((a, [k ,v]) => (a[k] = (() => {
|
||||
const [lang] = k.split('-');
|
||||
switch (k) {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"type": "module"
|
||||
}
|
Loading…
Reference in New Issue