mirror of
https://github.com/imputnet/cobalt.git
synced 2026-02-11 16:34:13 +00:00
internal changes only
- remade config module - renamed loc to i18n because that's what all developers do - moved code to src to make repo look cleaner - fixed some i18n strings
This commit is contained in:
22
src/modules/sub/i18n.js
Normal file
22
src/modules/sub/i18n.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { supportedLanguages, appName, repo } from "../config.js";
|
||||
import loadJson from "./load-json.js";
|
||||
|
||||
export default function(lang, cat, string, replacement) {
|
||||
if (!supportedLanguages.includes(lang)) {
|
||||
lang = 'en'
|
||||
}
|
||||
try {
|
||||
let str = loadJson(`./src/i18n/${lang}/${cat}.json`);
|
||||
if (str && str[string]) {
|
||||
let s = str[string].replace(/\n/g, '<br/>').replace(/{appName}/g, appName).replace(/{repo}/g, repo)
|
||||
if (replacement) {
|
||||
s = s.replace(/{s}/g, replacement)
|
||||
}
|
||||
return s + ' '
|
||||
} else {
|
||||
return string
|
||||
}
|
||||
} catch (e) {
|
||||
return string
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user