{"id":17872229,"url":"https://github.com/hkaraoglu/language-translator","last_synced_at":"2025-08-13T18:34:39.240Z","repository":{"id":80654776,"uuid":"140101036","full_name":"hkaraoglu/language-translator","owner":"hkaraoglu","description":"Text localization and language translation module for nodeJS","archived":false,"fork":false,"pushed_at":"2019-08-23T14:07:45.000Z","size":49,"stargazers_count":16,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-09T09:43:24.717Z","etag":null,"topics":["express-js","expressjs","language-translator","localisation","localization","multilanguage","nodejs","string","text","translator-text-api"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/language-translator","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hkaraoglu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-07T16:45:44.000Z","updated_at":"2024-06-11T15:24:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"dc32b47d-289f-4435-86f3-83339fb442ad","html_url":"https://github.com/hkaraoglu/language-translator","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":0.1707317073170732,"last_synced_commit":"f590837731f2d3a1e36e82d3accd502d018a7131"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/hkaraoglu/language-translator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkaraoglu%2Flanguage-translator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkaraoglu%2Flanguage-translator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkaraoglu%2Flanguage-translator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkaraoglu%2Flanguage-translator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hkaraoglu","download_url":"https://codeload.github.com/hkaraoglu/language-translator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkaraoglu%2Flanguage-translator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269735101,"owners_count":24466796,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express-js","expressjs","language-translator","localisation","localization","multilanguage","nodejs","string","text","translator-text-api"],"created_at":"2024-10-28T10:40:41.559Z","updated_at":"2025-08-13T18:34:39.152Z","avatar_url":"https://github.com/hkaraoglu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\n\n# language-translator\nText localization and translation module for NodeJS Express Framework.\n\n## **Install**\n\n    npm install language-translator --save\n\n\n## **Load**\n\n    var  languageTranslator = require('language-translator');\n    app.use(languageTranslator.init(\n      {\n        langs          : [\"tr\", \"en\", \"fr\", \"de\", \"es\"], // ... And other languages\n        defaultLang    : \"en\",\n\t    cookieName     : \"lang\",\n\t    translate      : \"true\",\n        translationApiKey: \"{{your_yandex_translate_api_key}}\"\n    }));\n\n\n\n\n## Configuration Parameters\n\n **langs**\n\nThe module creates folders which takes an json array from configuration json. The array is required.\n\n\n **defaultLang**\n\nThe module choose a language to choose a language folder as a default when cookie language is not be set. The defaultLang is required.\n\n\n**langDir**\n\nThe module creates a root folder which takes its name from configuration json. The langDir is optional. Default value is\n*language*.\n\n**cookieName**\n\nThe module creates a cookie to know user's language preference which requested before. Default cookie name is *language*.\n\n**equalizeKeys**\n\nThe module offer an option to equalize keys of default language's json files with other languages. For example, you created a json file in default language folder but not in other language folders. When you restart node server, module creates all files and keys in other language folders for you. Default value is true. (Recommended)\n\n**translate**\n\nThe module offer translate default language files to another language by using Yandex Translator API. Default value is true. (Recommended)\n\n**translationApiKey** :\n\nIf you want translate all texts in default language folder's json files, you have to create API key in Yandex Developers Page. (https://translate.yandex.com/developers/keys) . It's free. This parameter is required if parameter *translate* is **true**.\n\nNotice: If you use translation, you have to define items in ***langs*** array like below:\n\n**Supported Language List:**\n\n\u003ctable\u003e \u003ctbody\u003e      \u003ctr\u003e\u003cth width=\"175\"\u003eLanguage\u003c/th\u003e\u003cth width=\"175\"\u003eCode\u003c/th\u003e\u003cth width=\"175\"\u003eLanguage\u003c/th\u003e\u003cth width=\"175\"\u003eCode\u003c/th\u003e\u003c/tr\u003e   \u003ctr\u003e\u003ctd width=\"175\"\u003eAzerbaijan\u003c/td\u003e\u003ctd width=\"175\"\u003eaz\u003c/td\u003e\u003ctd width=\"175\"\u003eMalayalam\u003c/td\u003e\u003ctd width=\"175\"\u003eml\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eAlbanian\u003c/td\u003e\u003ctd width=\"175\"\u003esq\u003c/td\u003e\u003ctd width=\"175\"\u003eMaltese\u003c/td\u003e\u003ctd width=\"175\"\u003emt\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eAmharic\u003c/td\u003e\u003ctd width=\"175\"\u003eam\u003c/td\u003e\u003ctd width=\"175\"\u003eMacedonian\u003c/td\u003e\u003ctd width=\"175\"\u003emk\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eEnglish\u003c/td\u003e\u003ctd width=\"175\"\u003een\u003c/td\u003e\u003ctd width=\"175\"\u003eMaori\u003c/td\u003e\u003ctd width=\"175\"\u003emi\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eArabic\u003c/td\u003e\u003ctd width=\"175\"\u003ear\u003c/td\u003e\u003ctd width=\"175\"\u003eMarathi\u003c/td\u003e\u003ctd width=\"175\"\u003emr\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eArmenian\u003c/td\u003e\u003ctd width=\"175\"\u003ehy\u003c/td\u003e\u003ctd width=\"175\"\u003eMari\u003c/td\u003e\u003ctd width=\"175\"\u003emhr\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eAfrikaans\u003c/td\u003e\u003ctd width=\"175\"\u003eaf\u003c/td\u003e\u003ctd width=\"175\"\u003eMongolian\u003c/td\u003e\u003ctd width=\"175\"\u003emn\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eBasque\u003c/td\u003e\u003ctd width=\"175\"\u003eeu\u003c/td\u003e\u003ctd width=\"175\"\u003eGerman\u003c/td\u003e\u003ctd width=\"175\"\u003ede\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eBashkir\u003c/td\u003e\u003ctd width=\"175\"\u003eba\u003c/td\u003e\u003ctd width=\"175\"\u003eNepali\u003c/td\u003e\u003ctd width=\"175\"\u003ene\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eBelarusian\u003c/td\u003e\u003ctd width=\"175\"\u003ebe\u003c/td\u003e\u003ctd width=\"175\"\u003eNorwegian\u003c/td\u003e\u003ctd width=\"175\"\u003eno\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eBengali\u003c/td\u003e\u003ctd width=\"175\"\u003ebn\u003c/td\u003e\u003ctd width=\"175\"\u003ePunjabi\u003c/td\u003e\u003ctd width=\"175\"\u003epa\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eBurmese\u003c/td\u003e\u003ctd width=\"175\"\u003emy\u003c/td\u003e\u003ctd width=\"175\"\u003ePapiamento\u003c/td\u003e\u003ctd width=\"175\"\u003epap\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eBulgarian\u003c/td\u003e\u003ctd width=\"175\"\u003ebg\u003c/td\u003e\u003ctd width=\"175\"\u003ePersian\u003c/td\u003e\u003ctd width=\"175\"\u003efa\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eBosnian\u003c/td\u003e\u003ctd width=\"175\"\u003ebs\u003c/td\u003e\u003ctd width=\"175\"\u003ePolish\u003c/td\u003e\u003ctd width=\"175\"\u003epl\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eWelsh\u003c/td\u003e\u003ctd width=\"175\"\u003ecy\u003c/td\u003e\u003ctd width=\"175\"\u003ePortuguese\u003c/td\u003e\u003ctd width=\"175\"\u003ept\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eHungarian\u003c/td\u003e\u003ctd width=\"175\"\u003ehu\u003c/td\u003e\u003ctd width=\"175\"\u003eRomanian\u003c/td\u003e\u003ctd width=\"175\"\u003ero\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eVietnamese\u003c/td\u003e\u003ctd width=\"175\"\u003evi\u003c/td\u003e\u003ctd width=\"175\"\u003eRussian\u003c/td\u003e\u003ctd width=\"175\"\u003eru\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eHaitian (Creole)\u003c/td\u003e\u003ctd width=\"175\"\u003eht\u003c/td\u003e\u003ctd width=\"175\"\u003eCebuano\u003c/td\u003e\u003ctd width=\"175\"\u003eceb\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eGalician\u003c/td\u003e\u003ctd width=\"175\"\u003egl\u003c/td\u003e\u003ctd width=\"175\"\u003eSerbian\u003c/td\u003e\u003ctd width=\"175\"\u003esr\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eDutch\u003c/td\u003e\u003ctd width=\"175\"\u003enl\u003c/td\u003e\u003ctd width=\"175\"\u003eSinhala\u003c/td\u003e\u003ctd width=\"175\"\u003esi\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eHill Mari\u003c/td\u003e\u003ctd width=\"175\"\u003emrj\u003c/td\u003e\u003ctd width=\"175\"\u003eSlovakian\u003c/td\u003e\u003ctd width=\"175\"\u003esk\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eGreek\u003c/td\u003e\u003ctd width=\"175\"\u003eel\u003c/td\u003e\u003ctd width=\"175\"\u003eSlovenian\u003c/td\u003e\u003ctd width=\"175\"\u003esl\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eGeorgian\u003c/td\u003e\u003ctd width=\"175\"\u003eka\u003c/td\u003e\u003ctd width=\"175\"\u003eSwahili\u003c/td\u003e\u003ctd width=\"175\"\u003esw\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eGujarati\u003c/td\u003e\u003ctd width=\"175\"\u003egu\u003c/td\u003e\u003ctd width=\"175\"\u003eSundanese\u003c/td\u003e\u003ctd width=\"175\"\u003esu\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eDanish\u003c/td\u003e\u003ctd width=\"175\"\u003eda\u003c/td\u003e\u003ctd width=\"175\"\u003eTajik\u003c/td\u003e\u003ctd width=\"175\"\u003etg\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eHebrew\u003c/td\u003e\u003ctd width=\"175\"\u003ehe\u003c/td\u003e\u003ctd width=\"175\"\u003eThai\u003c/td\u003e\u003ctd width=\"175\"\u003eth\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eYiddish\u003c/td\u003e\u003ctd width=\"175\"\u003eyi\u003c/td\u003e\u003ctd width=\"175\"\u003eTagalog\u003c/td\u003e\u003ctd width=\"175\"\u003etl\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eIndonesian\u003c/td\u003e\u003ctd width=\"175\"\u003eid\u003c/td\u003e\u003ctd width=\"175\"\u003eTamil\u003c/td\u003e\u003ctd width=\"175\"\u003eta\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eIrish\u003c/td\u003e\u003ctd width=\"175\"\u003ega\u003c/td\u003e\u003ctd width=\"175\"\u003eTatar\u003c/td\u003e\u003ctd width=\"175\"\u003ett\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eItalian\u003c/td\u003e\u003ctd width=\"175\"\u003eit\u003c/td\u003e\u003ctd width=\"175\"\u003eTelugu\u003c/td\u003e\u003ctd width=\"175\"\u003ete\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eIcelandic\u003c/td\u003e\u003ctd width=\"175\"\u003eis\u003c/td\u003e\u003ctd width=\"175\"\u003eTurkish\u003c/td\u003e\u003ctd width=\"175\"\u003etr\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eSpanish\u003c/td\u003e\u003ctd width=\"175\"\u003ees\u003c/td\u003e\u003ctd width=\"175\"\u003eUdmurt\u003c/td\u003e\u003ctd width=\"175\"\u003eudm\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eKazakh\u003c/td\u003e\u003ctd width=\"175\"\u003ekk\u003c/td\u003e\u003ctd width=\"175\"\u003eUzbek\u003c/td\u003e\u003ctd width=\"175\"\u003euz\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eKannada\u003c/td\u003e\u003ctd width=\"175\"\u003ekn\u003c/td\u003e\u003ctd width=\"175\"\u003eUkrainian\u003c/td\u003e\u003ctd width=\"175\"\u003euk\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eCatalan\u003c/td\u003e\u003ctd width=\"175\"\u003eca\u003c/td\u003e\u003ctd width=\"175\"\u003eUrdu\u003c/td\u003e\u003ctd width=\"175\"\u003eur\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eKyrgyz\u003c/td\u003e\u003ctd width=\"175\"\u003eky\u003c/td\u003e\u003ctd width=\"175\"\u003eFinnish\u003c/td\u003e\u003ctd width=\"175\"\u003efi\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eChinese\u003c/td\u003e\u003ctd width=\"175\"\u003ezh\u003c/td\u003e\u003ctd width=\"175\"\u003eFrench\u003c/td\u003e\u003ctd width=\"175\"\u003efr\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eKorean\u003c/td\u003e\u003ctd width=\"175\"\u003eko\u003c/td\u003e\u003ctd width=\"175\"\u003eHindi\u003c/td\u003e\u003ctd width=\"175\"\u003ehi\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eXhosa\u003c/td\u003e\u003ctd width=\"175\"\u003exh\u003c/td\u003e\u003ctd width=\"175\"\u003eCroatian\u003c/td\u003e\u003ctd width=\"175\"\u003ehr\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eKhmer\u003c/td\u003e\u003ctd width=\"175\"\u003ekm\u003c/td\u003e\u003ctd width=\"175\"\u003eCzech\u003c/td\u003e\u003ctd width=\"175\"\u003ecs\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eLaotian\u003c/td\u003e\u003ctd width=\"175\"\u003elo\u003c/td\u003e\u003ctd width=\"175\"\u003eSwedish\u003c/td\u003e\u003ctd width=\"175\"\u003esv\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eLatin\u003c/td\u003e\u003ctd width=\"175\"\u003ela\u003c/td\u003e\u003ctd width=\"175\"\u003eScottish\u003c/td\u003e\u003ctd width=\"175\"\u003egd\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eLatvian\u003c/td\u003e\u003ctd width=\"175\"\u003elv\u003c/td\u003e\u003ctd width=\"175\"\u003eEstonian\u003c/td\u003e\u003ctd width=\"175\"\u003eet\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eLithuanian\u003c/td\u003e\u003ctd width=\"175\"\u003elt\u003c/td\u003e\u003ctd width=\"175\"\u003eEsperanto\u003c/td\u003e\u003ctd width=\"175\"\u003eeo\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eLuxembourgish\u003c/td\u003e\u003ctd width=\"175\"\u003elb\u003c/td\u003e\u003ctd width=\"175\"\u003eJavanese\u003c/td\u003e\u003ctd width=\"175\"\u003ejv\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eMalagasy\u003c/td\u003e\u003ctd width=\"175\"\u003emg\u003c/td\u003e\u003ctd width=\"175\"\u003eJapanese\u003c/td\u003e\u003ctd width=\"175\"\u003eja\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd width=\"175\"\u003eMalay\u003c/td\u003e\u003ctd width=\"175\"\u003ems\u003c/td\u003e\u003ctd width=\"175\"\u003e\u003c/td\u003e\u003ctd width=\"175\"\u003e\u003c/td\u003e\u003c/tr\u003e  \u003c/tbody\u003e \u003c/table\u003e\n\n\n\n\n\n## Usage\n\nWhen your app started, firstly the module creates **language** folder in root directory. Then, it creates folders which names are in **langs** array.  Then, it creates a json file which name is same as its folder name for common texts. And it creates a mapping.json file which is used to match route paths and language files.\n\n**For example:**\n\n    langs : [\"tr\", \"en\"]\n\n\n ---\n\n     your_app_folder\n         -\u003e language\n    \t      -\u003e tr\n    \t        -\u003e tr.json // It creates for common texts\n    \t\t-\u003e And your other language files...\n    \t      -\u003e en\n    \t\t-\u003e en.json // It creates for common texts\n    \t\t-\u003e And your other language files...\n\n\n--\n**en.json file content:**\n\n    {\n    \t\"example\"           : \"Example Text\",\n    \t\"example_with_param\": \"Example %s\"\n    }\n\n**On view file usage (Example for .ejs):**\n\n    \u003c%=  _lt.get('example')  %\u003e\n\n**Formatted:**\n\n    \u003c%=  _lt.get(example_with_param, \"Param value\")  %\u003e\n\n--\n\n**On js file usage**\n\n     var _lt = res.locals._lt;\n     _lt.load(\"home\");\n     console.log(_lt.get(\"example_with_param\", \"Param value\"));\n---\n\n\nExample:\n\n**Your Application directory:**\n\n     your_app_folder\n         -\u003e language\n    \t      -\u003e tr\n    \t        -\u003e tr.json // It is used for common texts\n    \t\t-\u003e home.json\n    \t\t-\u003e about.json\n\t\t\t-\u003e users.json\n    \t      -\u003e en\n\t\t\t-\u003e en.json // It is used for common texts\n\t\t\t-\u003e home.json\n\t\t\t-\u003e about.json\n\t\t\t-\u003e users.json   \n\n\n\nPlease **STAR** and **WATCH** the project! :)\n\n\n**References**:\n“Medium.com - Nodejs text localization module” https://medium.com/@hkaraoglutr/nodejs-text-localization-module-687d3d285c3a\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkaraoglu%2Flanguage-translator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhkaraoglu%2Flanguage-translator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkaraoglu%2Flanguage-translator/lists"}