{"id":16170431,"url":"https://github.com/corentinth/browser-i18n","last_synced_at":"2026-04-27T20:33:02.781Z","repository":{"id":95926513,"uuid":"137064199","full_name":"CorentinTh/browser-i18n","owner":"CorentinTh","description":"A simple in-browser i18n module, compatible with the i18n-node server module data files. Meant to be use with a module bundler (like parcel).","archived":false,"fork":false,"pushed_at":"2018-08-13T16:13:27.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T15:06:45.690Z","etag":null,"topics":["browser","browser-i18n","i18n","javascript","npm-package"],"latest_commit_sha":null,"homepage":null,"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/CorentinTh.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":"2018-06-12T11:50:25.000Z","updated_at":"2023-09-08T17:41:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"90debba2-bd6e-453c-b910-f52694e27dfa","html_url":"https://github.com/CorentinTh/browser-i18n","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"f5fe8daf60646db6119cecb07ed9aca259fc9150"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorentinTh%2Fbrowser-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorentinTh%2Fbrowser-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorentinTh%2Fbrowser-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorentinTh%2Fbrowser-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CorentinTh","download_url":"https://codeload.github.com/CorentinTh/browser-i18n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247611201,"owners_count":20966492,"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","browser-i18n","i18n","javascript","npm-package"],"created_at":"2024-10-10T03:18:44.202Z","updated_at":"2026-04-27T20:33:02.750Z","avatar_url":"https://github.com/CorentinTh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# browser-i18n\n\nA simple in-browser i18n module, compatible with the [i18n-node](https://github.com/mashpie/i18n-node) server module data files. Meant to be use with a module bundler (like [parcel](https://parceljs.org)).\n\n## Installation\n\nBy using npm:\n\n```\nnpm i browser-i18n --save\n```\n\n## Usage\n\n```javascript\nimport I18n from 'browser-i18n';\n\nconst i18n = new I18n({\n    language: 'fr',\n    path: '/locales',\n    extension: '.json'\n});\n\nconsole.log( i18n.__('Hello') );\n// Output: 'Bonjour'\n\nconsole.log( i18n.__('Oh, hi %s!', 'Mark') );\n// Output: 'Oh, salut Mark!'\n\n\n// Or using the global selector ...\n\nconsole.log( __('Hello') );\n// Output: 'Bonjour'\n```\n\n\n### Files structures\n\nOne file for each language. They may have the following structure:\n\n```json\n// /locales/en.json\n\n{\n  \"Hello\": \"Hello\",\n  \"Oh, hi %s!\": \"Oh, hi %s!\",\n  \"Bye!\": \"Bye!\"\n}\n```\n```json\n// /locales/fr.json\n\n{\n  \"Hello\": \"Bonjour\",\n  \"Oh, hi %s!\": \"Oh, salut %s!\",\n  \"Bye!\": \"Au revoir!\"\n}\n```\n\nPut your locales folder accessible publicly. You can do it by putting it in your public root:\n\n```\n.\n└── public\n    └── locales\n        ├── en.json\n        └── fr.json\n```\n\nOr, using express:\n\n```javascript\napp.use('/locales', express.static(path.join(__dirname, 'locales')));\n```\n\n## API\n\nConfiguration:\n\n```javascript\nconst i18n = new I18n({\n    language: 'fr',     // The langage wanted - Default 'en'\n    path: '/locales',   // The path to access the locales files - Default '/locales'\n    extension: '.json', // Local file extension - Default '.json'\n    setGobal: true,     // Set the function '__' on a global scope - Default true\n    onReady: callback,  // Set a callback triggered when the dataFile is loaded\n    verbose: true       // Set the verbosity of the object - Default to true\n});\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorentinth%2Fbrowser-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorentinth%2Fbrowser-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorentinth%2Fbrowser-i18n/lists"}