refactor(locales): use es module

This commit is contained in:
Kagami Sascha Rosylight 2023-07-09 00:27:00 +02:00
parent 74a05ec739
commit 5bd0228da2
3 changed files with 10 additions and 7 deletions

View File

@ -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 = [

View File

@ -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) {

3
locales/package.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "module"
}