Skip to content

MostFeatured/LocaleTransformator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LocaleTransformator

Locale Class Into A Yaml File Or Reverse

Example

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");

})();

About

Locale Class Into A Yaml Or Reverse

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published