{"id":24373410,"url":"https://github.com/Vidigal-code/BPT-Pro-Libretranslate","last_synced_at":"2025-09-29T08:31:04.694Z","repository":{"id":273076561,"uuid":"918626369","full_name":"Vidigal-code/BPT-Pro","owner":"Vidigal-code","description":"An open-source translation plugin for browsers allows real-time translation of web pages. It supports multiple languages ​​and can automatically detect and translate text into the user’s preferred language. Being open-source, it is continually improved by the community to stay up-to-date and optimized.","archived":false,"fork":false,"pushed_at":"2025-01-18T13:56:00.000Z","size":2798,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T14:48:20.139Z","etag":null,"topics":["browser-extension","css","html","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vidigal-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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":"2025-01-18T12:40:26.000Z","updated_at":"2025-01-18T14:03:20.000Z","dependencies_parsed_at":"2025-01-18T14:48:29.951Z","dependency_job_id":"d9dbca9b-ab1b-46e7-a078-4018e09f40fb","html_url":"https://github.com/Vidigal-code/BPT-Pro","commit_stats":null,"previous_names":["vidigal-code/bpt-pro"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vidigal-code%2FBPT-Pro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vidigal-code%2FBPT-Pro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vidigal-code%2FBPT-Pro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vidigal-code%2FBPT-Pro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vidigal-code","download_url":"https://codeload.github.com/Vidigal-code/BPT-Pro/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234600997,"owners_count":18858546,"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","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":["browser-extension","css","html","javascript"],"created_at":"2025-01-19T05:11:12.459Z","updated_at":"2025-09-29T08:31:04.687Z","avatar_url":"https://github.com/Vidigal-code.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BPT-Pro-Libretranslate\n\n**BPT-Pro-Libretranslate** is a project developed to provide a powerful text translation tool, using the best available\ntranslation APIs. This project allows users to configure the API URL, set the desired target language, and quickly\ntranslate selected text on web pages.\n\n## Example\n\n![GIF Example](https://github.com/Vidigal-code/BPT-Pro-Libretranslate/blob/main/example/example-1.gif?raw=true)\n\n## Features\n\n- **API Configuration**: Configure the API URL and API key for translation services.\n- **Multiple Language Support**: Translate text into various languages, such as English, Spanish, French, Portuguese,\n  and more.\n- **Popup Display**: Displays translations in an elegant popup on the screen after selecting text on a webpage.\n- **User-Friendly Interface**: The extension provides a simple interface for users to manage settings and customize\n  their translation experience.\n\n## Installation\n\n### Steps to Install\n\n1. **Download or Clone the Repository**:\n    - You can either download the ZIP file of the repository or clone the repository using Git:\n\n   ```bash\n   git clone https://github.com/Vidigal-code/BPT-Pro-Libretranslate.git\n   ```\n\n2. **Load the Extension in Chrome or Edge**:\n\n   ![Tutorial 1](https://github.com/Vidigal-code/BPT-Pro-Libretranslate/blob/main/example/tutorial-3.png?raw=true)\n\n    - Open your browser and go to the extensions page (`chrome://extensions` for Chrome or `edge://extensions` for\n      Edge).\n    - Enable Developer Mode (toggle in the top-right corner).\n\n   ![Tutorial 1](https://github.com/Vidigal-code/BPT-Pro-Libretranslate/blob/main/example/tutorial-0.png?raw=true)\n\n    - Click on **Load Unpacked** and select the folder where you downloaded or cloned the repository.\n\n   ![Tutorial 1](https://github.com/Vidigal-code/BPT-Pro-Libretranslate/blob/main/example/tutorial-1.png?raw=true)\n\n4. **Configure the Extension**:\n    - Click on the extension icon in the browser toolbar.\n    - Enter the API URL and the API key for the translation service.\n    - Select the target language for translation.\n    - API Test:  https://translate.fedilab.app/translate\n    - API Test Key: unknown\n\n   ![Tutorial 1](https://github.com/Vidigal-code/BPT-Pro-Libretranslate/blob/main/example/example-2.png?raw=true)\n\n### Start Using\n\nOnce configured, simply select text on any webpage, and the translation will appear in a popup.\n\n## Usage\n\n1. **Select Text**: Highlight the text on a webpage.\n2. **Translation Popup**: The translation of the selected text will appear in a popup.\n3. **Close Popup**: Click the \"X\" button on the popup to close it.\n4. **Configure Settings**: If needed, you can change the API URL, API key, or target language via the settings page.\n5. **Plugin Status**: Activate the plugin.\n\n## Example Code\n\n```javascript\nasync function translateText(text, targetLanguage, apiUrl, apiKey) {\n    const response = await fetch(apiUrl, {\n        method: 'POST',\n        headers: {\n            'Accept': 'application/json',\n            'Content-Type': 'application/x-www-form-urlencoded',\n        },\n        body: new URLSearchParams({\n            q: text,\n            source: 'auto',\n            api_key: apiKey,\n            target: targetLanguage,\n            format: 'text'\n        }),\n    });\n\n    const data = await response.json();\n\n    if (data.error) {\n       // console.error('Translation API error:', data.error);\n        return `Error: ${data.error}`;\n    }\n\n    return data.translatedText;\n}\n```\n\nTo implement the keyboard shortcuts you mentioned in your code (`Alt + A` to activate the plugin, `Alt + K` to\ndeactivate the plugin, `Alt + G` to toggle the plugin status, and `Alt + T` to test or open the test connection menu),\nyou can modify the existing `setupKeyboardShortcuts` function. Here’s the updated version of the code with these\nspecific shortcuts added:\n\n```javascript\n/**\n * Sets up keyboard shortcuts to activate/deactivate the plugin, test connection, and toggle the plugin status.\n */\nsetupKeyboardShortcuts()\n{\n    document.addEventListener('keydown', (event) =\u003e {\n        if (event.altKey) {\n            switch (event.key.toUpperCase()) {\n                case 'A': // Alt + A to activate the plugin\n                    this.togglePluginStatus(true);\n                    break;\n                case 'K': // Alt + K to deactivate the plugin\n                    this.togglePluginStatus(false);\n                    break;\n                case 'G': // Alt + G to toggle the plugin status (activate if deactivated, deactivate if active)\n                    event.preventDefault();\n                    this.togglePluginStatus();\n                    break;\n                case 'T': // Alt + T to open the test connection menu\n                    event.preventDefault();\n                    const apiTestPopup = new ApiTestPopup();\n                    apiTestPopup.createApiTestListPopup();\n                    break;\n                default:\n                    break;\n            }\n        }\n    });\n}\n```\n\n### Explanation of the Key Shortcuts:\n\n1. **Alt + A**: Activates the plugin (calls `togglePluginStatus(true)`).\n2. **Alt + K**: Deactivates the plugin (calls `togglePluginStatus(false)`).\n3. **Alt + G**: Toggles the plugin status. If it is active, it will deactivate it; if it is inactive, it will activate\n   it (calls `togglePluginStatus()`).\n4. **Alt + T**: Opens the test connection menu by calling the `ApiTestPopup` constructor and its\n   `createApiTestListPopup` method.\n\nThis will allow users to control the plugin's activation and deactivation with keyboard shortcuts, providing a more\nseamless user experience. Make sure that the `togglePluginStatus` function and `ApiTestPopup` class are properly\nimplemented in your project for this to work correctly.\n\n## Technologies Used\n\n- **HTML**: Used to create the extension’s settings page and popup.\n- **CSS**: Used to style and create a responsive interface for the extension.\n- **JavaScript**: Handles the logic for translating selected text and manages the interactions between the extension and\n  the browser.\n- **Chrome/Edge Extension APIs**: Allows communication between the browser and the extension, manages storage of\n  settings, and handles the popup behavior.\n\n# License\n\nThis project is licensed under the **MIT License**.\n\nSee the [LICENSE](https://github.com/Vidigal-code/BPT-Pro-Libretranslate/blob/main/License.mit) file for more details.\n\n# License - API\n\nThis project is licensed api under the **MIT License**.\n\nSee the [LICENSE](https://github.com/LibreTranslate/LibreTranslate/blob/main/LICENSE) file for more details.\n\n---\n\n## Credits\n\n- **Creator**: Kauan Vidigal\n- **Translation API**: [LibreTranslate](https://libretranslate.com/)\n- **Contributions**: Contributions are welcome! Feel free to fork the repository, open an issue, or submit a pull\n  request for improvements or new features.\n\n## Links\n\n- [LibreTranslate API Documentation](https://libretranslate.com/docs)\n- [LibreTranslate API GitHub](https://github.com/LibreTranslate/LibreTranslate)\n\n---\n\nFeel free to modify and enhance this project to suit your needs!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVidigal-code%2FBPT-Pro-Libretranslate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FVidigal-code%2FBPT-Pro-Libretranslate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVidigal-code%2FBPT-Pro-Libretranslate/lists"}