{"id":29866506,"url":"https://github.com/marcmartinezdev/fast-react-i18n","last_synced_at":"2026-01-20T17:27:40.670Z","repository":{"id":304801000,"uuid":"1020031993","full_name":"MarcMartinezDev/fast-react-i18n","owner":"MarcMartinezDev","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-15T09:04:02.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-15T19:14:45.096Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/MarcMartinezDev.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,"zenodo":null}},"created_at":"2025-07-15T08:34:41.000Z","updated_at":"2025-07-15T09:04:05.000Z","dependencies_parsed_at":"2025-07-15T19:55:54.668Z","dependency_job_id":"d8e0a0ff-5c84-433a-82b1-e2a01d91328c","html_url":"https://github.com/MarcMartinezDev/fast-react-i18n","commit_stats":null,"previous_names":["marcmartinezdev/fast-react-i18n"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/MarcMartinezDev/fast-react-i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcMartinezDev%2Ffast-react-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcMartinezDev%2Ffast-react-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcMartinezDev%2Ffast-react-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcMartinezDev%2Ffast-react-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcMartinezDev","download_url":"https://codeload.github.com/MarcMartinezDev/fast-react-i18n/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcMartinezDev%2Ffast-react-i18n/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267867859,"owners_count":24157363,"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-07-30T02:00:09.044Z","response_time":70,"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":[],"created_at":"2025-07-30T12:39:27.625Z","updated_at":"2026-01-20T17:27:40.635Z","avatar_url":"https://github.com/MarcMartinezDev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌍 fast-react-i18n\n\nMinimalist internationalization library for React with support for language detection, fallback, in-memory/localStorage caching, and dynamic loading of translations from JSON files.\n\n---\n\n## ✨ Characteristics\n\n- ✅ Dynamic loading of translation files (/es.json, /en.json, etc.)\n- 🌐 Automatic detection of the user’s language (?lang, cookies, browser)\n- 💾 In-memory cache and optional persistence via localStorage\n- 📉 Automatic fallback if the language is not found\n- ⚡ Quick access hooks: useTranslation, useForceReloadTranslations, etc.\n- 🧽 Cache clearing function: clearTranslationsCache\n- 🌎 Loading available languages via locales.json\n\n---\n\n## 🚀 Instalation\n\n```bash\nnpm install fast-react-i18n\n```\n\n## 📦 Expected translations structure\n\n```bash\npublic/\n  └── locales/\n      ├── en.json\n      ├── es.json\n      └── locales.json  ← [\"en\", \"es\"...]\n```\n\n## 🧩 Basic usage\n\n1. Envolve your App\n\n```bash\nimport { I18nProvider } from \"fast-react-i18n\";\n\n\u003cI18nProvider\n  initialLocale=\"auto\"\n  fallbackLocale=\"en\"\n  translationsPath=\"/locales\"\n  persist\n\u003e\n  \u003cApp /\u003e\n\u003c/I18nProvider\u003e\n```\n\n2. Access translations\n\n```bash\nimport { useTranslation } from \"fast-react-i18n\";\n\nexport const Home = () =\u003e {\n  const { translations } = useTranslation();\n\n  return \u003ch1\u003e{translations.home?.title}\u003c/h1\u003e;\n};\n```\n\n## 🛠 API\n\n```bash\n\u003cI18nProvider /\u003e\n| Propiedad           | Tipo      | Descripción                                                               |\n|---------------------|-----------|---------------------------------------------------------------------------|\n| `initialLocale`     | `string?` | Initial Lang (`\"en\"`, `\"es\"`... default `\"auto\"`)                         |\n| `fallbackLocale`    | `string?` | Alternative language if the primary one fails                             |\n| `translationsPath`  | `string`  | Base path to your translation files (e.g., /locales)                      |\n| `persist`           | `boolean?`| Whether to save in localStorage (default: false)                          |\n```\n\n## Functions\n\n### useForceReloadTranslations()\n\nManually reloads the current language.\n\n### detectUserLocale()\n\nDetects the user’s preferred language, in this order:\n\n- Query param ?lang=\n- Cookie lang=\n- navigator.language\n- \"en\" (by default)\n\n### clearTranslationsCache()\n\nDeletes from localStorage all translations stored under keys starting with i18n\\_.\n\n### loadAvailableLocales(path: string): Promise\u003cstring[]\u003e\n\nLoads an array with the languages defined in locales.json.\n\n## 💡 Best practices\n\nUse nested objects for your translations ({ home: { title: \"\" } })\n\nControl the language with setLocale if you need to change it manually\n\nClear the cache if translations change dynamically (e.g., from a CMS)\n\nUse fallbackLocale to avoid errors if a file is missing\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcmartinezdev%2Ffast-react-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcmartinezdev%2Ffast-react-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcmartinezdev%2Ffast-react-i18n/lists"}