utils.js 348 B

123456789101112
  1. import { fileURLToPath } from 'url'
  2. import fs from 'fs'
  3. import Path from 'path'
  4. const __dirname = fileURLToPath(new URL('.', import.meta.url))
  5. const LOCALES_FOLDER = Path.join(__dirname, '../../locales')
  6. export function loadLocale(language) {
  7. return JSON.parse(
  8. fs.readFileSync(Path.join(LOCALES_FOLDER, `${language}.json`), 'utf-8')
  9. )
  10. }