https://github.com/mostfeatured/localetransformator
Locale Class Into A Yaml Or Reverse
https://github.com/mostfeatured/localetransformator
Last synced: 3 months ago
JSON representation
Locale Class Into A Yaml Or Reverse
- Host: GitHub
- URL: https://github.com/mostfeatured/localetransformator
- Owner: MostFeatured
- Created: 2022-09-09T12:52:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-25T16:35:32.000Z (over 2 years ago)
- Last Synced: 2025-02-18T15:51:44.490Z (3 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LocaleTransformator
Locale Class Into A Yaml File Or Reverse
## Example
```js
const { createDBI } = require("@mostfeatured/dbi");
const { localeToYamlFile, yamlFileToLocaleFile, yamlAsLocale, importFromInteractionYamlPack, packInteractionLocalesAsYamls } = require("@mostfeatured/locale-transformer");const dbi = createDBI("dbi_namespace", {
discord: {
token: "Your Token Here",
options: {
intents: ["Guilds"]
}
}
});dbi.register(({ Locale }) => {
Locale({
name: "tr",
data: {
erdem: {
isim: "Erdem",
},
türk: "Türk"
}
});
});(async () => {
switch ("fromHere") {case "fromPack": {
importFromInteractionYamlPack("./yamls", dbi);
};case "fromHere": {
dbi.register(({ Locale, InteractionLocale }) => {Locale(yamlAsLocale("./en.yaml"));
InteractionLocale({
name: "cinsiyet seç",
data: {
tr: {
name: "cinsiyet seç",
description: "...",
options: {
cinsiyet: {
name: "cinsiyet",
description: "...",
choices: {
"Erkek": "Erkek",
"Kadın": "Kadın"
}
}
}
},
en: {
name: "gender pick",
description: "...",
options: {
cinsiyet: {
name: "gender",
description: "...",
choices: {
"Erkek": "Male",
"Kadın": "Female"
}
}
}
}
}
});
});
}}
await dbi.load();
// packing interaction locales into a file
await packInteractionLocalesAsYamls(dbi.data.interactionLocales, "./yamls");console.log(dbi.data.interactionLocales)
await localeToYamlFile(dbi.data.locales.get("tr"), "./tr.yaml");
await yamlFileToLocaleFile("./tr.yaml", "./tr.js");
})();
```