{"id":17937732,"url":"https://github.com/beanbaginc/babel-plugin-django-gettext","last_synced_at":"2026-02-05T23:32:34.920Z","repository":{"id":143845688,"uuid":"253997485","full_name":"beanbaginc/babel-plugin-django-gettext","owner":"beanbaginc","description":"Babel plugin that simplifies using Django's JavaScript gettext functions","archived":false,"fork":false,"pushed_at":"2024-04-07T09:17:40.000Z","size":242,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-29T11:28:25.572Z","etag":null,"topics":["babel","babel-plugin","es6","gettext","i18n","javascript","localization"],"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/beanbaginc.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":"AUTHORS","dei":null}},"created_at":"2020-04-08T05:51:19.000Z","updated_at":"2024-02-09T04:04:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e8d2a14-6335-433c-ae53-6dbb553231fd","html_url":"https://github.com/beanbaginc/babel-plugin-django-gettext","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/beanbaginc/babel-plugin-django-gettext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beanbaginc%2Fbabel-plugin-django-gettext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beanbaginc%2Fbabel-plugin-django-gettext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beanbaginc%2Fbabel-plugin-django-gettext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beanbaginc%2Fbabel-plugin-django-gettext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beanbaginc","download_url":"https://codeload.github.com/beanbaginc/babel-plugin-django-gettext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beanbaginc%2Fbabel-plugin-django-gettext/sbom","scorecard":{"id":229399,"data":{"date":"2025-08-11","repo":{"name":"github.com/beanbaginc/babel-plugin-django-gettext","commit":"8666c9992f1c660eecb3c7396f820918931edf56"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"32 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-x3m3-4wpv-5vgc","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6","Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T04:33:48.883Z","repository_id":143845688,"created_at":"2025-08-17T04:33:48.883Z","updated_at":"2025-08-17T04:33:48.883Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29138375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T23:14:48.546Z","status":"ssl_error","status_checked_at":"2026-02-05T23:14:35.724Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["babel","babel-plugin","es6","gettext","i18n","javascript","localization"],"created_at":"2024-10-28T23:07:12.299Z","updated_at":"2026-02-05T23:32:34.903Z","avatar_url":"https://github.com/beanbaginc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# babel-plugin-django-gettext\n\nThis plugin simplifies gettext-based localization in your\n[Django](https://www.djangoproject.com/)-backed JavaScript codebases, giving\nyou the ability to use word wrapping, template literals, and string\ninterpolation, avoiding the mess of overly-long strings and sprinkled\n`interpolate()` calls.\n\n\n## Installation\n\n```\n$ npm install babel babel-plugin-django-gettext\n$ babel --plugins django-gettext script.js\n```\n\nIf you're using TypeScript, you will want to reference the types by including\nthe following in your TypeScript files or in a `global.d.ts` file:\n\n```typescript\n/// \u003creference types=\"babel-plugin-django-gettext\"/\u003e\n```\n\n\n## Usage\n\nThere are two ways to work with this enhanced gettext support:\n\n1. You can call functions (like `_(...)`, `gettext(...)`, `ngettext(...)`,\n   etc.) and pass in strings or template literals, as you did before, like:\n\n    ```javascript\n    const str = _('Ready to have fun?');\n    ```\n\n2. You can use tagged templates, which looks cooler. See?\n\n    ```javascript\n    const str = _`Ready to have fun?`;\n    ```\n\nIn either case, you'll get automatic interpolation and controlled whitespace\nsupport for free. We'll go over that in a minute.\n\n\n### Gettext functions\n\nFirst, let's cover all the gettext functions that can be directly called:\n\n* `_` (alias for `gettext`)\n* `N_` (alias for `ngettext`)\n* `gettext`\n* `gettext_raw`\n* `gettext_noop`\n* `gettext_noop_raw`\n* `ngettext`\n* `ngettext_raw`\n* `pgettext`\n* `pgettext_raw`\n* `npgettext`\n* `npgettext_raw`\n\nAnd here's what you can use for a tagged template literal:\n\n* `_` (alias for `gettext`)\n* `N_` (alias for `ngettext`)\n* `gettext`\n* `gettext_raw`\n* `gettext_noop`\n* `gettext_noop_raw`\n\n\n### Whitespace Rules\n\nThe `_raw` versions will preserve any and all whitespace. For example:\n\n```javascript\n// So  this:\nconst str = gettext_raw('   This  has  some\\n    whitespace\\n    going on ');\n\n// Or   maybe   this:\nconst str = gettext_raw(`   This  has  some\n    whitespace\n    going on `);\n\n// Turns    into:\nconst str = gettext(\"   This  has  some\\n    whitespace\\n    going on \");\n```\n\nPretty obvious. Works the way you're used to today.\n\nThe non-raw versions will split your text into paragraphs (separated by one or\nmore blank lines), collapse down whitespace and trim all leading and\ntrailing whitespace in each paragraph, and trim the resulting string:\n\n```javascript\n// So  this:\nconst str = gettext(\"   This  has  some\\n    whitespace\\n      going on.\\n\\nOh and here's another paragraph.\\n\\n    \");\n\n// Or   maybe   this:\nconst str = gettext(`   This  has  some\n    whitespace\n      going on.\n\n    Oh and here's another paragaraph.\n\n       `);\n\n// Turns into:\nconst str = gettext(\"This has some whitespace going on.\\n\\nOh and here's another paragraph.\");\n```\n\nMuch cleaner, and probably want you usually want in your message files.\n\nThe non-raw versions make it really easy to carefully compose your message\nacross multiple lines without affecting the resulting string. The raw versions\nare there if that whitespace matters.\n\n\n### Automatic Interpolation\n\nWhenever you use a template literal containing referenced variables or\nexpressions, an `interpolate(...)` call will be made for you.\n\nFor example:\n\n```javascript\nconst subject = 'world';\n\n// These are equivalent:\nconst str = _`Hello ${subject}!`;\nconst str = gettext(`Hello ${subject}!`);\n\n// That becomes:\nvar subject = 'world';\nvar str = interpolate(gettext(\"Hello %(subject)s!\"),\n                      {subject: subject},\n                      true);\n```\n\nThis even works for `ngettext()` calls:\n\n```javascript\nconst count = 2;\nconst str = ngettext(`The button was only clicked ${count} time!`,\n                     `The button was clicked ${count} times!`,\n                     count);\n\n// That becomes:\nvar count = 4;\nvar str = interpolate(ngettext(\"The button was only clicked %(count)s time!\",\n                               \"The button was clicked %(count)s times!\",\n                               count),\n                      {count: count},\n                      true);\n```\n\nFor everything but the `ngettext`/`pngettext` variants, you can also\nuse expressions:\n\n```javascript\nconst count = 4;\nconst str = _`There are ${count + 1} lights!`;\n\n// Giving us:\nvar count = 4;\nvar str = interpolate(gettext(\"There are %(value1)s lights!\"),\n                      {value1: count + 1},\n                      true);\n```\n\n\n### Works With Other Tagged Templates\n\nFan of the [dedent](https://www.npmjs.com/package/babel-plugin-dedent)\ntagged template plugin? Combine it with any of the raw gettext functions,\nlike so:\n\n```javascript\nconst n = 4;\nconst str = gettext_raw(dedent`\n    Here we've got lots of text, which may have\n    newlines and\n        ${n} space indentation\n`);\n\n\n// That becomes:\nvar n = 4;\nvar str = interpolate(\n    gettext(\"Here we've got lots of text, which may have\\nnewlines and\\n    %(n)s space indentation\"),\n    {n: n},\n    true);\n```\n\nIsn't that much nicer to maintain?\n\nIt's not just that one, either. Most tagged templates should be compatible\n(as long as they don't need to manage their own expressions/variable references,\nbecause this plugin will be preparing them for interpolation first).\n\n\n# Examples\n\nLet's cover just a few more real-world examples, using the most common\ngettext methods:\n\n\n## `_`, `gettext`\n\n```javascript\n// These are all equivalent:\nconst s = _`Let's localize!`;\nconst s = _`\n      Let's  localize!\n    `;\nconst s = _(`Let's localize!`);\nconst s = _(\"Let's localize!\");\nconst s = gettext`Let's localize!`;\nconst s = gettext(`Let's localize!`);\nconst s = gettext(\"Let's localize!\");\n\n// So are these:\nconst s = _`i = ${i}`;\nconst s = _(`i = ${i}`);\nconst s = gettext`i = ${i}`;\nconst s = gettext(`i = ${i}`);\nconst s = interpolate(gettext(\"i = %(i)s\"), {i: i}, true);\n```\n\n\n## `gettext_raw`\n\n```javascript\n// These are all equivalent:\nconst s = gettext_raw`  Let's\n  localize!`;\nconst s = gettext_raw(\"  Let's\\n  localize!\");\n\n// So are these:\nconst s = gettext_raw`  i  =  ${i}\n`;\nconst s = gettext_raw(\"  i  =  ${i}\\n\");\nconst s = interpolate(gettext_raw(\"  i  =  %(i)s\\n\"),\n                      {i: i},\n                      true);\n```\n\n\n## `N_`, `ngettext`\n\n```javascript\n// These are all equivalent:\nconst s = N_('There is only one',\n             'There are many',\n             count);\nconst s = ngettext('There is only one',\n                   'There are many',\n                   count);\n\n// So are these:\nconst s = N_(`There is only ${i}`,\n             `There are ${i}`,\n             count);\nconst s = ngettext(`There is only ${i}`,\n                   `There are ${i}`,\n                   count);\nconst s = interpolate(ngettext(\"There is only %(i)s\",\n                               \"There are %(i)s\",\n                               count),\n                      {i: i},\n                      true);\n```\n\n\n# Where is this used?\n\nWe use `babel-plugin-django-gettext` at [Beanbag](http://www.beanbaginc.com/)\nfor our [Review Board](http://www.reviewboard.org/) and\n[RBCommons](https://rbcommons.com/) products, along with many of our other\n[open source projects](https://www.beanbaginc.com/opensource/).\n\nIf you use this plugin, let us know and we'll add your project to this section!\n\n\n# License\n\nCopyright (C) 2020 Beanbag, Inc. Released under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeanbaginc%2Fbabel-plugin-django-gettext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeanbaginc%2Fbabel-plugin-django-gettext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeanbaginc%2Fbabel-plugin-django-gettext/lists"}