overleaf/services/web/scripts/translations/utils.js
Liangjun Song 8293771f58 Merge pull request #21290 from overleaf/ls-scripts-to-esm-translations
Migrate scripts/translation to esm

GitOrigin-RevId: 475ec949f0ba238791df91de109169584e68c701
2024-10-25 08:06:12 +00:00

12 lines
348 B
JavaScript

import { fileURLToPath } from 'url'
import fs from 'fs'
import Path from 'path'
const __dirname = fileURLToPath(new URL('.', import.meta.url))
const LOCALES_FOLDER = Path.join(__dirname, '../../locales')
export function loadLocale(language) {
return JSON.parse(
fs.readFileSync(Path.join(LOCALES_FOLDER, `${language}.json`), 'utf-8')
)
}