{"id":21607602,"url":"https://github.com/jonirinta-kahila/localization-react","last_synced_at":"2026-05-07T03:34:47.636Z","repository":{"id":36952911,"uuid":"369192738","full_name":"JoniRinta-Kahila/localization-react","owner":"JoniRinta-Kahila","description":"Easy package that allows localization with React","archived":false,"fork":false,"pushed_at":"2023-03-06T15:30:30.000Z","size":3225,"stargazers_count":1,"open_issues_count":18,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-25T21:05:35.457Z","etag":null,"topics":["localization","npm","npm-package","react","reactjs","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/localization-react","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JoniRinta-Kahila.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-20T12:00:00.000Z","updated_at":"2023-01-31T18:54:47.000Z","dependencies_parsed_at":"2025-01-24T19:41:53.008Z","dependency_job_id":null,"html_url":"https://github.com/JoniRinta-Kahila/localization-react","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JoniRinta-Kahila/localization-react","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoniRinta-Kahila%2Flocalization-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoniRinta-Kahila%2Flocalization-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoniRinta-Kahila%2Flocalization-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoniRinta-Kahila%2Flocalization-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoniRinta-Kahila","download_url":"https://codeload.github.com/JoniRinta-Kahila/localization-react/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoniRinta-Kahila%2Flocalization-react/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265445503,"owners_count":23766493,"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":["localization","npm","npm-package","react","reactjs","typescript"],"created_at":"2024-11-24T20:32:22.142Z","updated_at":"2026-05-07T03:34:47.568Z","avatar_url":"https://github.com/JoniRinta-Kahila.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-localization\n\n`npm i localization-react`\n\n## languages.ts\n```ts\n// add supported languages here\nconst Languages = {\n  FI: 'fi',\n  EN: 'en',\n}\n\nexport default Languages;\n\n```\n\n## locales.json\n```json\n{\n  \"EN\": {\n    \"home\": {\n      \"string_1\": \"Hello, World!\",\n      \"string_2\": \"This is English.\"\n    }\n  },\n  \"FI\": {\n    \"home\": {\n      \"string_1\": \"Hei, Maailma!\",\n      \"string_2\": \"Tämä on Suomea.\"\n    }\n  }\n}\n```\n\n## app.tsx\n\n```ts\nimport React from 'react';\nimport LocalizationContextProvider from 'localization-react';\nimport Languages from './localization/languages';\nimport LanguageSwitch from './localization/LanguageSwitch';\nimport Home from './home';\n\nconst App: React.FC = () =\u003e {\n  return (\n    \u003cLocalizationContextProvider languageList={Languages} defaultLanguage='FI'\u003e\n      \u003cLanguageSwitch /\u003e\n      \u003cHome /\u003e\n    \u003c/LocalizationContextProvider\u003e\n  )\n}\n\nexport default App;\n\n```\n\n## Home.tsx, translated page\n\n```ts\nimport React from 'react';\nimport { Translator, useLocalization } from 'localization-react';\nimport localesJson from './localization/locales.json';\n\nconst Home: React.FC = () =\u003e {\n  const localization = useLocalization();\n  const translator = new Translator(localesJson, 'home', localization.language);\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003e{translator.getLocaleString('string_1')}\u003c/h1\u003e\n      \u003ch1\u003e{translator.getLocaleString('string_2')}\u003c/h1\u003e\n    \u003c/div\u003e\n  )\n}\n\nexport default Home;\n\n```\n\n## languageSwitch.tsx, switch between languages\n\n```ts\nimport React from 'react';\nimport { useLocalization } from 'localization-react';\n\nconst LanguageSwitch: React.FC = () =\u003e {\n  const localization = useLocalization();\n  const radioHandler = (event: React.ChangeEvent\u003cHTMLInputElement\u003e) =\u003e {\n    console.log(event.target.value)\n    localization.selectLanguage(event.target.value);\n  };\n  return (\n    \u003cdiv\u003e\n      \u003cinput\n        type='radio'\n        value='EN'\n        name='lang'\n        id='en'\n        checked={localization.language === \"EN\"}\n        onChange={radioHandler}\n      /\u003e\n      \u003clabel htmlFor='en'\u003eEnglish\u003c/label\u003e\n      \u003cinput\n        type='radio'\n        value='FI'\n        name='lang'\n        id='fi'\n        checked={localization.language === \"FI\"}\n        onChange={radioHandler}\n      /\u003e\n      \u003clabel htmlFor='fi'\u003eFinnish\u003c/label\u003e\n    \u003c/div\u003e\n  )\n}\n\nexport default LanguageSwitch;\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonirinta-kahila%2Flocalization-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonirinta-kahila%2Flocalization-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonirinta-kahila%2Flocalization-react/lists"}