UNPKG

ethiopic-localization

Version:
49 lines (39 loc) 1.38 kB
async function ethiopicLocalization(words, language, key) { // Check if API key is passed if (!key) return { status: "Error", message: "Localization key required!", }; const axios = require("axios"); const BASE_URL = require("./constants/index"); // Function wich converts all the words to lower cases const WordsToLowerCase = require("./helpers/WordsToLowerCase"); const wordsInlowerCase = WordsToLowerCase(words); // Request for tranlation using the words in lowercase. const res = await axios.put( `${BASE_URL}/dictionary/dictionaries/searchDictionaryWithListMobile/`, (words = { words: wordsInlowerCase }), { headers: { key: key }, } ); // A function to check if translations found for every words. const CheckWordsTranslations = require("./helpers/CheckWordsTranslations"); // Getting formated words . const formatedWords = CheckWordsTranslations( words, res.data.data[language], language ); return formatedWords; } async function ethiopicLanguages() { // API to fetch all languages const { languagesAPI } = require("./API/index"); const axios = require("axios"); // Requesting to get all languages const res = await axios.get(languagesAPI); return res.data; } module.exports = { ethiopicLocalization, ethiopicLanguages };