nigeria-translator-browser
Version:
A lightweight and developer-friendly Node.js + TypeScript package for translating between English and major Nigerian languages — Igbo, Yoruba, and Hausa. Provides simple bidirectional translation functions (English ↔ Igbo, Yoruba, Hausa). Created with lov
17 lines (16 loc) • 728 B
JavaScript
import translate from "translate";
// Use MyMemory free engine
translate.engine = "google";
translate.key = undefined;
// Generic translate function
export async function translateText(text, to, from = "en") {
return await translate(text, { from, to });
}
// English → Nigerian
export const englishToIgbo = (text) => translateText(text, "ig");
export const englishToYoruba = (text) => translateText(text, "yo");
export const englishToHausa = (text) => translateText(text, "ha");
// Nigerian → English
export const igboToEnglish = (text) => translateText(text, "en", "ig");
export const yorubaToEnglish = (text) => translateText(text, "en", "yo");
export const hausaToEnglish = (text) => translateText(text, "en", "ha");