{"id":26489091,"url":"https://github.com/rigelglen/cordova-plugin-mlkit-translate","last_synced_at":"2025-08-20T22:08:20.965Z","repository":{"id":57140875,"uuid":"227605025","full_name":"rigelglen/cordova-plugin-mlkit-translate","owner":"rigelglen","description":"Cordova Plugin that implements MLKit Translation and Language Identification features.","archived":false,"fork":false,"pushed_at":"2020-05-19T09:14:22.000Z","size":45,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-27T19:22:06.232Z","etag":null,"topics":["cordova","cordova-android-plugin","cordova-ios-plugin","cordova-plugin","firebase","mlkit"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/rigelglen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-12T12:44:54.000Z","updated_at":"2024-08-31T06:11:51.000Z","dependencies_parsed_at":"2022-09-01T23:51:41.335Z","dependency_job_id":null,"html_url":"https://github.com/rigelglen/cordova-plugin-mlkit-translate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rigelglen/cordova-plugin-mlkit-translate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rigelglen%2Fcordova-plugin-mlkit-translate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rigelglen%2Fcordova-plugin-mlkit-translate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rigelglen%2Fcordova-plugin-mlkit-translate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rigelglen%2Fcordova-plugin-mlkit-translate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rigelglen","download_url":"https://codeload.github.com/rigelglen/cordova-plugin-mlkit-translate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rigelglen%2Fcordova-plugin-mlkit-translate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271393817,"owners_count":24751782,"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-20T02:00:09.606Z","response_time":69,"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":["cordova","cordova-android-plugin","cordova-ios-plugin","cordova-plugin","firebase","mlkit"],"created_at":"2025-03-20T07:19:52.690Z","updated_at":"2025-08-20T22:08:20.944Z","avatar_url":"https://github.com/rigelglen.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cordova MLKit Translation\n\n[![npm](https://img.shields.io/npm/v/cordova-plugin-mlkit-translate?style=for-the-badge)](https://www.npmjs.com/package/cordova-plugin-mlkit-translate)\n[![npm](https://img.shields.io/npm/dt/cordova-plugin-mlkit-translate?style=for-the-badge)](https://www.npmjs.com/package/cordova-plugin-mlkit-translate)\n[![NPM](https://img.shields.io/npm/l/cordova-plugin-mlkit-translate?style=for-the-badge)](LICENSE)\n\nCordova Plugin that implements MLKit Translation and Language Identification features.\n\nSupports both iOS and Android.\n\nThis plugin uses Google's MLKit On-device Translation services, so make sure you follow the steps to create a firebase project ([Android](https://firebase.google.com/docs/android/setup) | [iOS](https://firebase.google.com/docs/ios/setup)) up to step 3 (where you get the google-services.json or GoogleService-Info.plist). Ignore if you already have google-services.json or GoogleService-Info.plist files.\n\nAdditionally, make sure you follow [Google's usage guidelines](https://firebase.google.com/docs/ml-kit/translation-terms) for MLKit usage.\n\nFor translation, MLKit and by extension this plugin support the [following languages](https://firebase.google.com/docs/ml-kit/translation-language-support).\n\nFor language identification, the plugin supports the [following languages](https://firebase.google.com/docs/ml-kit/langid-support).\n\n#### Table of Contents\n\n - [Installation](#installation)\n \t- [Version support](#version-support)\n \t- [Dependencies](#dependencies)\n - [Variables](#variables)\n - [API](#api)\n \t- [translate](#translate)\n \t- [identifyLanguage](#identifylanguage) \t \t\n \t- [getDownloadedModels](#getdownloadedmodels)\n \t- [getAvailableModels](#getavailablemodels)\n \t- [downloadModel](#downloadmodel)\n \t- [deleteModel](#deletemodel)\n\n\n## Installation\n\n- Install the plugin by adding it to your project's config.xml:\n\n```\n\u003cplugin name=\"cordova-plugin-mlkit-translate\" spec=\"latest\" /\u003e\n```\n\nor\n\n```\ncordova plugin add cordova-plugin-mlkit-translate\n```\n\n- *(Optional) If you're using ionic, make sure you use the Ionic native wrapper.*\n```\nnpm install @ionic-native/mlkit-translate\n```\n\n- **Make sure you have your google-services.json or GoogleService-Info.plist file in your project's root folder.**\n\n### Version Support\n\n- cordova `\u003e=9`\n- cordova-android `\u003e=8`\n- cordova-ios `\u003e=5`\n\n### Dependencies\n\n- This plugin depends on [cordova-plugin-firebasex](https://github.com/dpa99c/cordova-plugin-firebasex) on Android.\n- This plugin depends on [cordova-plugin-add-swift-support](https://github.com/akofman/cordova-plugin-add-swift-support) on iOS.\n\n\n## Variables\nThese variables are android only\n\n|                  Variable                  | Default |\n| :----------------------------------------: | :-----: |\n|    FIREBASE_ML_NATURAL_LANGUAGE_VERSION    | 22.0.0  |\n| FIREBASE_ML_NATURAL_LANGUAGE_MODEL_VERSION | 20.0.7  |\n|  FIREBASE_ML_NATURAL_LANGUAGE_ID_VERSION   | 20.0.7  |\n\n## API\n\nYou can access all these methods via the window[\"MLKitTranslate\"] object. \n\nIf you're using the Ionic Native wrapper, then add the plugin to your module\n\n```\nimport { MLKitTranslate } from '@ionic-native/mlkit-translate/ngx';\n@NgModule({\n  declarations: [AppComponent],\n  entryComponents: [],\n  imports: [\n    ...\n  ],\n  providers: [\n    ...\n    MLKitTranslate,\n    ...\n  ],\n  bootstrap: [AppComponent]\n})\nexport class AppModule {}\n```\n\nAnd then inject it into the component you want.\n\n```\nimport { MLKitTranslate } from '@ionic-native/ml-kit-translate';\n\nconstructor(private mlkitTranslate: MLKitTranslate) { }\n...\n```\n\n#### translate\n\nTranslates text from one language to another. Requires the source and target languages need to be downloaded. If not the languages are downloaded in the background automatically.\n\n##### Parameters\n\n- {string} text - text to be translated\n- {string} targetLanguage - language code of the language to translate to\n- {string} sourceLanguage - (optional) language code of the language to translate from, if not present the language is inferred.\n- {function} success - (promisified in ionic native wrapper) callback function which takes a parameter data which will be invoked on success\n- {function} error - (promisified in ionic native wrapper) callback function which takes a parameter err which will be invoked on failure\n\n##### Example\n\n```\nwindow[\"MLKitTranslate\"].translate(\"hello\", \"es\", \"en\",\n    (data)=\u003econsole.log(`Translated text is ${data}`),\n    (err)=\u003econsole.log(\"Something went wrong with the translation\")\n})\n// prints Translated text is hola\n```\n\nwith Ionic Native\n\n```\nthis.mlkitTranslate.translate(\"hello\", \"es\", \"en\").then(translatedText=\u003e{\n    console.log(`Translated text is ${translatedText}`)\n})\n// prints Translated text is hola\n```\n\n#### identifyLanguage\n\nDetermines the language of a string of text.\n\n##### Parameters\n\n- {string} text - text to be identified\n- {function} success - (promisified in ionic native wrapper) callback function which takes a parameter data which will be invoked on success\n- {function} error - (promisified in ionic native wrapper) callback function which takes a parameter err which will be invoked on failure\n\n#### Data format\n\nSuccess data will be a language object with two properties\n\n- {string} code - [BCP-47](https://en.wikipedia.org/wiki/IETF_language_tag) language code\n- {string} displayName - Name of the language\n\n##### Example\n\n```\nwindow[\"MLKitTranslate\"].identifyLanguage(\"hello\",\n    (data)=\u003econsole.log(\"Identified text is\",  data),\n    (err)=\u003econsole.log(\"Something went wrong with the translation\")\n})\n\n// prints Identified text is {\"code\": \"en\", \"displayName\": \"English\"}\n```\n\nor with Ionic Native\n\n```\nthis.mlkitTranslate.identifyLanguage(\"hello\").then(lang=\u003e{\n    console.log(\"Identified text is \", lang);\n})\n\n// prints Identified text is {\"code\": \"en\", \"displayName\": \"English\"}\n```\n\n#### getDownloadedModels\n\nList of language models that have been downloaded to the device.\n\n##### Parameters\n\n- {function} success - (promisified in ionic native wrapper) callback function which takes a parameter data which will be invoked on success\n- {function} error - (promisified in ionic native wrapper) callback function which takes a parameter err which will be invoked on failure\n\n##### Data format\n\nSuccess data will be an array with language objects (see above)\n\n##### Example\n\n```\nwindow[\"MLKitTranslate\"].getDownloadedModels(\n    (data)=\u003econsole.log(data),\n    (err)=\u003econsole.log(err)\n})\n\n// prints [{\"code\": \"en\", \"displayName\": \"English\"}]\n```\n\nor with Ionic Native\n\n```\nthis.mlkitTranslate.getDownloadedModels().then(langs=\u003e{\n    console.log(langs);\n})\n\n// prints [{\"code\": \"en\", \"displayName\": \"English\"}]\n```\n\n#### getAvailableModels\n\nList of language models that can be downloaded.\n\n##### Parameters\n\n- {function} success - (promisified in ionic native wrapper) callback function which takes a parameter data which will be invoked on success\n- {function} error - (promisified in ionic native wrapper) callback function which takes a parameter err which will be invoked on failure\n\n##### Data format\n\nSuccess data will be an array with language objects (see above)\n\n##### Example\n\n```\nwindow[\"MLKitTranslate\"].getAvailableModels(\n    (data)=\u003econsole.log(data),\n    (err)=\u003econsole.log(err)\n})\n\n// prints [{\"code\": \"en\", \"displayName\": \"English\"}, {\"code\", \"es\", \"displayName\": \"Spanish\"}, ...]\n```\n\nor with Ionic Native\n\n```\nthis.mlkitTranslate.getAvailableModels().then(langs=\u003e{\n    console.log(langs);\n})\n\n// prints [{\"code\": \"en\", \"displayName\": \"English\"}, {\"code\", \"es\", \"displayName\": \"Spanish\"}, ...]\n```\n\n#### downloadModel\n\nDownloads a specified language model.\n\n##### Parameters\n\n- {string} code - [BCP-47](https://en.wikipedia.org/wiki/IETF_language_tag) language code of the language to download\n- {function} success - (promisified in ionic native wrapper) callback function which takes a parameter data which will be invoked on success\n- {function} error - (promisified in ionic native wrapper) callback function which takes a parameter err which will be invoked on failure\n\n##### Data format\n\nSuccess data will be a language object of the downloaded language.\n\n##### Example\n\n```\nwindow[\"MLKitTranslate\"].downloadModel(\"es\",\n    (data)=\u003econsole.log(data),\n    (err)=\u003econsole.log(err)\n})\n\n// prints {\"code\", \"es\", \"displayName\": \"Spanish\"}\n```\n\nor with Ionic Native\n\n```\nthis.mlkitTranslate.downloadModel(\"es\").then(lang=\u003e{\n    console.log(lang);\n})\n\n// prints {\"code\", \"es\", \"displayName\": \"Spanish\"}\n```\n\n#### deleteModel\n\nDelete a specified language model.\n\n##### Parameters\n\n- {string} code - [BCP-47](https://en.wikipedia.org/wiki/IETF_language_tag) language code of the language to delete\n- {function} success - (promisified in ionic native wrapper) callback function which takes a parameter data which will be invoked on success\n- {function} error - (promisified in ionic native wrapper) callback function which takes a parameter err which will be invoked on failure\n\n##### Data format\n\nSuccess data will be a language object of the deleted language.\n\n##### Example\n\n```\nwindow[\"MLKitTranslate\"].deleteModel(\"es\",\n    (data)=\u003econsole.log(data),\n    (err)=\u003econsole.log(err)\n})\n\n// prints {\"code\", \"es\", \"displayName\": \"Spanish\"}\n```\n\nor with Ionic Native\n\n```\nthis.mlkitTranslate.deleteModel(\"es\").then(lang=\u003e{\n    console.log(lang);\n})\n\n// prints {\"code\", \"es\", \"displayName\": \"Spanish\"}\n```\n\n## LICENSE\n\nThis plugin is licensed under the [MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frigelglen%2Fcordova-plugin-mlkit-translate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frigelglen%2Fcordova-plugin-mlkit-translate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frigelglen%2Fcordova-plugin-mlkit-translate/lists"}