{"id":39106393,"url":"https://github.com/zamarrowski/translate-components","last_synced_at":"2026-01-17T19:28:14.315Z","repository":{"id":48431575,"uuid":"88892781","full_name":"zamarrowski/translate-components","owner":"zamarrowski","description":"🌎🌍🌏  translate-components provides a super simple translation for React.","archived":false,"fork":false,"pushed_at":"2018-11-16T11:55:40.000Z","size":1671,"stargazers_count":15,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T17:54:12.500Z","etag":null,"topics":["multilanguage","multilingual","react","react-translate","translate","tratranslate-components"],"latest_commit_sha":null,"homepage":"","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/zamarrowski.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":"2017-04-20T17:30:54.000Z","updated_at":"2023-11-01T23:12:10.000Z","dependencies_parsed_at":"2022-09-02T20:41:28.232Z","dependency_job_id":null,"html_url":"https://github.com/zamarrowski/translate-components","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zamarrowski/translate-components","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zamarrowski%2Ftranslate-components","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zamarrowski%2Ftranslate-components/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zamarrowski%2Ftranslate-components/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zamarrowski%2Ftranslate-components/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zamarrowski","download_url":"https://codeload.github.com/zamarrowski/translate-components/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zamarrowski%2Ftranslate-components/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28516935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T18:55:29.170Z","status":"ssl_error","status_checked_at":"2026-01-17T18:55:03.375Z","response_time":85,"last_error":"SSL_read: 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":["multilanguage","multilingual","react","react-translate","translate","tratranslate-components"],"created_at":"2026-01-17T19:28:13.731Z","updated_at":"2026-01-17T19:28:14.310Z","avatar_url":"https://github.com/zamarrowski.png","language":"JavaScript","readme":"# translate-components 🌎🌍🌏\n[![Build Status](https://travis-ci.org/zamarrowski/translate-components.svg?branch=master)](https://travis-ci.org/zamarrowski/translate-components)\n\ntranslate-components provides a super simple translation for React. Write your application in your language and use translate-components to annotate which texts should be translated.\n\n# Demo\n![preview](https://raw.githubusercontent.com/zamarrowski/translate-components/master/preview.gif)\n\n# Features\n* Write in your language.\n* Instant translations without having to refresh your browser.\n* Easy to use.\n* Support for create-react-app.\n\n# Install\n```\nnpm install --save translate-components\n```\n# How to use\n```\n//index.js\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\nimport { TranslateProvider } from 'translate-components'\nimport './index.css';\nimport translations from './translations.json'\n\nReactDOM.render(\n  \u003cTranslateProvider translations={translations} defaultLanguage={'en'}\u003e\n    \u003cApp /\u003e\n  \u003c/TranslateProvider\u003e,\n  document.getElementById('root')\n);\n```\nWrap your application with TranslateProvider, pass the translations and the default language of your application.\n\n```\nimport React, { Component } from 'react';\nimport logo from './logo.svg';\nimport './App.css';\nimport Translate from 'translate-components'\nimport { reactTranslateChangeLanguage } from 'translate-components'\n\nclass App extends Component {\n  render() {\n    return (\n      \u003cdiv className=\"App\"\u003e\n        \u003cdiv className=\"App-header\"\u003e\n          \u003cimg src={logo} className=\"App-logo\" alt=\"logo\" /\u003e\n          \u003ch2\u003e\u003cTranslate\u003eWelcome to React\u003c/Translate\u003e\u003c/h2\u003e\n        \u003c/div\u003e\n        \u003cp className=\"App-intro\"\u003e\n          \u003cTranslate\u003eTo get started, edit\u003c/Translate\u003e \u003ccode\u003esrc/App.js\u003c/code\u003e \u003cTranslate\u003eand save to reload.\u003c/Translate\u003e\n        \u003c/p\u003e\n        \u003cdiv\u003e\n          \u003cbutton onClick={reactTranslateChangeLanguage.bind(this, 'en')}\u003e\n            English\n          \u003c/button\u003e\n          \u003cbutton onClick={reactTranslateChangeLanguage.bind(this, 'es')}\u003e\n            Spanish\n          \u003c/button\u003e\n          \u003cbutton onClick={reactTranslateChangeLanguage.bind(this, 'de')}\u003e\n            German\n          \u003c/button\u003e\n        \u003c/div\u003e\n      \u003c/div\u003e\n    );\n  }\n}\n\nexport default App;\n```\n\nUse ```Translate``` component to wrap the text you want to translate.\nUse ```reactTranslateChangeLanguage``` to change the language of your application. Pass to ```reactTranslateChangeLanguage``` function, as first argument, the language. This translate instantly your application!\n\nOf course, you need to have a translation **JSON** file to pass it to TranslateProvider like this:\n```\n{\n  \"Welcome to React\": {\n    \"es\": \"Bienvenido a React\",\n    \"de\": \"Willkommen in React\"\n  },\n  \"To get started, edit\": {\n    \"es\": \"Para empezar, edita\",\n    \"de\": \"Um loszulegen, bearbeiten\"\n  },\n  \"and save to reload.\": {\n    \"es\": \"y guarda para refrescar la pagina\",\n    \"de\": \"und speichern, um neu zu laden\"\n  }\n}\n```\n\nBy default the ```Translate``` component wraps the tranlated text into a ```\u003cspan\u003e``` element. Additionally, you can use the prop ```useRawText``` from the ```Translate``` component to render the tranlated text with no wrapping. This will be useful to render the text in elements that don't support nested ```\u003cspan\u003e``` as well as for other user cases like placeholders in ```\u003cinput\u003e``` elements. E.g.\n```\n\u003cselect className=\"selectClass\"\u003e\n  \u003coption value=\"phone\"\u003e\u003cTranslate useRawText={true}\u003ePhone\u003c/Translate\u003e\u003c/option\u003e\n  \u003coption value=\"email\"\u003e\u003cTranslate useRawText={true}\u003eEmail\u003c/Translate\u003e\u003c/option\u003e\n  \u003coption value=\"textMessage\"\u003e\u003cTranslate useRawText={true}\u003eText Message\u003c/Translate\u003e\u003c/option\u003e\n\u003c/select\u003e\n\n\u003cinput type=\"text\" name=\"phone\" className=\"form-control phone\" placeholder={\u003cTranslate useRawText={true}\u003eNúmero Telefónico\u003c/Translate\u003e} /\u003e\n\n```\n\n**The default language passed to TranslateProvider is the key of your translation objects.**\n\n# Extracting strings\nOnce we have our app annotated with **Translate** component it's now time to extract these strings automatically.\nTo extract these string we need to create a Javascript file that we will run with NodeJS.\nIn this file we should import **getTranslations**:\n```\nlet extractTranslations = require('./../translate-components/lib/getTranslations')\nextractTranslations.extract('./src/*.js', './src/translations.json', ['es', 'de'])\n```\nextractTranslations.extract() needs three params:\n* Files RegExp\n* File translation output\n* Languages\n\nIf a translation file not exist, translate-components will create a file but if it already exist will add the new translations.\nExecute node pathToYourFile.js and that will generate a translations file!\n\n## Debug mode (Highlight texts)\nEnable debug mode to higlight untranslated texts.\n```\n\u003cTranslateProvider debugMode={true} translations={translations} defaultLanguage={'en'}\u003e\n```\nWhen translate-components does not found a translate for a certain text this text will be higlighted with a background yellow. Demo:\n\n![highlight](https://raw.githubusercontent.com/zamarrowski/translate-components/master/highlight.gif)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzamarrowski%2Ftranslate-components","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzamarrowski%2Ftranslate-components","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzamarrowski%2Ftranslate-components/lists"}