{"id":15296176,"url":"https://github.com/joeybab3/phphtmltranslator","last_synced_at":"2026-02-17T18:35:37.809Z","repository":{"id":203194598,"uuid":"709045329","full_name":"joeybab3/phphtmltranslator","owner":"joeybab3","description":"PHP HTML Translator.","archived":false,"fork":false,"pushed_at":"2025-03-12T23:51:16.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-02T14:24:16.037Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/joeybab3.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":"2023-10-23T22:39:42.000Z","updated_at":"2025-03-12T23:51:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"2021f706-c625-4331-9dc9-bfaee4cbd239","html_url":"https://github.com/joeybab3/phphtmltranslator","commit_stats":null,"previous_names":["joeybab3/phphtmltranslator"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/joeybab3/phphtmltranslator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeybab3%2Fphphtmltranslator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeybab3%2Fphphtmltranslator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeybab3%2Fphphtmltranslator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeybab3%2Fphphtmltranslator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joeybab3","download_url":"https://codeload.github.com/joeybab3/phphtmltranslator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeybab3%2Fphphtmltranslator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29552798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T18:16:07.221Z","status":"ssl_error","status_checked_at":"2026-02-17T18:16:04.782Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-09-30T18:09:39.224Z","updated_at":"2026-02-17T18:35:32.799Z","avatar_url":"https://github.com/joeybab3.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phphtmltranslator\nPHP HTML Translator\n\nTranslates HTML into a destination language using Stichoza's Google Translate PHP:\nhttps://github.com/Stichoza/google-translate-php\n\nIt has all the same limitations, namely that since it uses the free Google Translate API, you may run into rate limits or a temporary IP Ban.\n\nIt uses a SQL database to cache previously translated tokens so running html through it repeatedly with only minor changes will be much faster.\n\n# Setup\n\n`composer require joeybab3/phphtmltranslator`\n\nOnce installed run the following PHP somewhere:\n```php\n\u003c?php\nrequire_once('vendor/autoload.php');\nuse Joeybab3\\HTMLTranslator\\HTMLTranslator as Translator;\n\n$dsn = \"mysql:host=127.0.0.1;dbname=database_name;charset=$charset\";\n$username = \"\";\n$password = \"\";\ntry {\n    $db = new PDO($dsn, $username, $password);\n} catch (\\PDOException $e) {\n    throw new \\PDOException($e-\u003egetMessage(), (int)$e-\u003egetCode());\n}\n\nTranslator::createTranslationCacheTable($db);\n```\n\nThis will create the cache table. Alternatively, create the table yourself:\n```sql\nCREATE TABLE `translations` (\n  `id` int unsigned NOT NULL AUTO_INCREMENT,\n  `text` text,\n  `result` text,\n  `lang` varchar(4) DEFAULT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\n```\n\nThen you can use it to translate HTML:\n```php\n\u003c?php\nrequire_once('vendor/autoload.php');\nuse Joeybab3\\HTMLTranslator\\HTMLTranslator as Translator;\n\n$TR = new Translator($db, \"es\"); // translate to Spanish\n$html = \"\u003cdiv class='test'\u003e\u003cspan\u003eThis text is not bold but \u003cb\u003ethis text is bold\u003c/b\u003e\u003c/span\u003e\u003cspan\u003eThis text, on the other hand, will be a separate translation entirely.\u003c/span\u003e\";\n\n$result = $TR-\u003etokenizedTranslate($html);\n\n// \u003cdiv class='test'\u003e\u003cspan\u003eEste texto no está en negrita pero \u003cb\u003eeste texto está en negrita\u003c/b\u003e\u003c/span\u003e\u003cspan\u003eEste texto, por otro lado, será una traducción completamente separada. \u003c/span\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeybab3%2Fphphtmltranslator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeybab3%2Fphphtmltranslator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeybab3%2Fphphtmltranslator/lists"}