{"id":22486738,"url":"https://github.com/ivantsov/webext-i18n","last_synced_at":"2025-07-26T11:19:45.909Z","repository":{"id":57153678,"uuid":"66720941","full_name":"ivantsov/webext-i18n","owner":"ivantsov","description":"Package for simplifying work with i18n in WebExtensions","archived":false,"fork":false,"pushed_at":"2016-12-02T22:13:50.000Z","size":36,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-08T02:49:42.827Z","etag":null,"topics":["chrome","firefox","i18n","internalization","localization","webextension"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/ivantsov.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}},"created_at":"2016-08-27T15:21:56.000Z","updated_at":"2023-09-08T17:14:09.000Z","dependencies_parsed_at":"2022-09-06T19:21:41.162Z","dependency_job_id":null,"html_url":"https://github.com/ivantsov/webext-i18n","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivantsov%2Fwebext-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivantsov%2Fwebext-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivantsov%2Fwebext-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivantsov%2Fwebext-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivantsov","download_url":"https://codeload.github.com/ivantsov/webext-i18n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228500184,"owners_count":17930006,"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":["chrome","firefox","i18n","internalization","localization","webextension"],"created_at":"2024-12-06T17:15:17.096Z","updated_at":"2024-12-06T17:16:07.836Z","avatar_url":"https://github.com/ivantsov.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# webext-i18n\n\n[![Build Status](https://travis-ci.org/ivantsov/webext-i18n.svg?branch=master)](https://travis-ci.org/ivantsov/webext-i18n)\n[![codecov](https://codecov.io/gh/ivantsov/webext-i18n/branch/master/graph/badge.svg)](https://codecov.io/gh/ivantsov/webext-i18n)\n[![npm version](https://badge.fury.io/js/webext-i18n.svg)](https://badge.fury.io/js/webext-i18n)\n\nThis package simplifies work with i18n in WebExtensions.\n\n### Install\n\n`npm install webext-i18n --save-dev`\n\n### Usage\n\nFor instance, you have the following structure:\n\n```\nsrc\n└── locales\n    ├── en.js\n    └── de.js   \n```\n\nAnd `en.js` may contain something like that:\n\n```js\n{\n    popup: {\n        title: 'Super title',\n        description: 'Super description',\n        buttons: {\n            login: 'Login',\n            remove: 'Remove account'\n        }\n    },\n    contentScript: {\n       action: 'Super action name',\n       text: 'Lorem ipsum',\n       items: [\n           'First item',\n           'Second item'\n       ]\n    }\n}\n```\n\nYeah, **nested** translation **entities without** specifying **`message` field**! And yes, it's not an appropriate format for WebExtensions, so you need to run the code below to generate a proper locales files:\n\n```js\nconst i18n = require('webext-i18n');\n\ni18n({\n    inputDir: './src/locales',\n    outputDir: './dist/locales'\n}).then(res =\u003e console.log('Generating locales is finished.');\n```\n\nIt will create `dist/locales` directory with `en.json` and `de.json` files inside. And `en.json` looks like that:\n\n```json\n{\n    \"popup_title\": {\n        \"message\": \"Super title\"\n    },\n    \"popup_description\": {\n        \"message\": \"Super description\"\n    },\n    \"popup_buttons_login\": {\n        \"message\": \"Login\"\n    },\n    \"popup_buttons_remove\": {\n        \"message\": \"Remove account\"\n    },\n    \"contentScript_action\": {\n        \"message\": \"Super action name\"\n    },\n    \"contentScript_text\": {\n        \"message\": \"Lorem ipsum\"\n    },\n    \"contentScript_items_0\": {\n        \"message\": \"First item\"\n    },\n    \"contentScript_items_1\": {\n        \"message\": \"Second item\"\n    }\n}\n```\n\n### API\n\nThe package contains only one method (the default export).\n\n#### Options\n\n- `inputDir` - directory with locales.\n\n- `outputDir` - directory where generated files should be placed.\n\nReturns a `Promise` that will be resolved when all locales are generated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivantsov%2Fwebext-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivantsov%2Fwebext-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivantsov%2Fwebext-i18n/lists"}