{"id":28318702,"url":"https://github.com/reececomo/gcomply","last_synced_at":"2025-10-15T09:27:22.407Z","repository":{"id":294608361,"uuid":"987386745","full_name":"reececomo/gcomply","owner":"reececomo","description":"Lightweight automatic grammar agreement engine for JavaScript/TypeScript","archived":false,"fork":false,"pushed_at":"2025-09-01T08:40:17.000Z","size":212,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-01T10:44:38.902Z","etag":null,"topics":["grammar","l10n","language","localization","natural-language","nlp"],"latest_commit_sha":null,"homepage":"http://npmjs.org/gcomply","language":"TypeScript","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/reececomo.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,"zenodo":null}},"created_at":"2025-05-21T02:18:26.000Z","updated_at":"2025-09-01T08:40:21.000Z","dependencies_parsed_at":"2025-05-21T08:38:40.133Z","dependency_job_id":"fb8acbda-d6ef-41d6-b69d-b30d4ec68df3","html_url":"https://github.com/reececomo/gcomply","commit_stats":null,"previous_names":["reececomo/gcomply"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/reececomo/gcomply","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reececomo%2Fgcomply","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reececomo%2Fgcomply/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reececomo%2Fgcomply/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reececomo%2Fgcomply/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reececomo","download_url":"https://codeload.github.com/reececomo/gcomply/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reececomo%2Fgcomply/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279066564,"owners_count":26096311,"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-10-15T02:00:07.814Z","response_time":56,"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":["grammar","l10n","language","localization","natural-language","nlp"],"created_at":"2025-05-25T08:11:29.094Z","updated_at":"2025-10-15T09:27:22.395Z","avatar_url":"https://github.com/reececomo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  🪡 GComply\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  Beautiful and natural-sounding text in human interfaces.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/gcomply\"\u003e\u003c!--\n  --\u003e\u003cimg alt=\"NPM version\" src=\"https://img.shields.io/npm/v/gcomply.svg\"\u003e\u003c!--\n  --\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/reececomo/gcomplyblob/main/LICENSE\"\u003e\u003c!--\n  --\u003e\u003cimg alt=\"License\" src=\"https://badgen.net/npm/license/gcomply\"\u003e\u003c!--\n  --\u003e\u003c/a\u003e\n  \u003ca href=\"https://bundlephobia.com/package/gcomply\"\u003e\u003c!--\n  --\u003e\u003cimg alt=\"Minzipped size\" src=\"https://badgen.net/bundlephobia/minzip/gcomply\"\u003e\u003c!--\n  --\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ctable align=\"center\"\u003e\u003ctr\u003e\u003ctd align=\"left\"\u003e\n  \n```ts\n`Add ${count} person to group.`       \n// ❌ \"Add 2 person to group.\"\n\ng`Add ${count} person to group.`\n// ✅ \"Add 2 people to group.\"\n```\n\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n\u003cp align=\"center\"\u003e\nLightweight \u003cstrong\u003eautomatic grammar agreement\u003c/strong\u003e.\n\u003c/p\u003e\n\n\u003e [!WARNING]\n\u003e **Experimental**: This is an experimental JavaScript API for automatic grammar\n\u003e agreement, modeled after the equivalent\n\u003e [Swift API](https://developer.apple.com/documentation/foundation/inflectionrule).\n\n## **🚀 Mission**\n\n- ✅ **What it is:**\nA lightweight engine for automatic grammar agreement \u0026ndash; scoped specifically for human\ninterfaces in software products. Provide fast, automatic grammar agreement to cover ~99%\nof real-world cases. Take the edge-case handling out of UI.\n\n- ❌ **What it is NOT:**\nPerfect or feature-complete grammar correction, stemming/lemmatization, lexical analysis,\nor sentiment analysis. This package will never \n\n\u003cdetails\u003e\u003csummary\u003e\u003ch4\u003e📘 Read more: Distinction from ICU Intl.MessageFormat\u003c/h4\u003e\u003c/summary\u003e\n\n**Intl.MessageFormat** provides manual support for plural/selects. But it is entirely\nmanual, and up to developers to predict all variance. It's also very challenging to\ncorrectly translate any string where a parameter (i.e. a noun) is interpolated.\n\n**Example:**\n\n```ts\nconst notification = t(\"I was in {country}\")\n// German: \"Ich war in {country}\"\n\nconst switzerland = t(\"Switzerland\")\n// German: \"die Schweiz\"\n\nnotification.format({ country: switzerland })\n// \"Ich war in die Schweiz\" ❌\n\n// The feminine dative article is \"der\" (not \n// \"die\") so it should instead be:\n// \"Ich war in der Schweiz\" ✅\n```\n\nIn this example if you supported 180+ countries, you might have a much bigger problem.\n\nSo to summarize, **ICU MessageFormat** is a great tool, but its focused primarily on a\ndifferent problem.\n\n\u003c/details\u003e\n\n### Add plurals\n\n```ts\nimport { Grammar, Plurals } from \"gcomply\";\n\nPlurals.getLang(\"en\").addTagged(Grammar.PartOfSpeech.noun,\n  { one: \"sausage\", other: \"sausages\" },\n  { one: \"twist\", other: \"twists\" },\n);\n```\n\n## ✨ Features\n\n- ⚡️ **Instant grammar agreement** — plurals, gender, articles, etc.\n- 📦 **Highly pluggable** — compatible with any other framework\n- 🌐 **Localizable** — add support for any natural language\n- 🪶 **Lightweight** — \u003c5kB, zero dependencies\n\nAdd custom transforms, domain terminology, nouns, pronouns, and more.\n\n## API Usage\n\n### Simple usage\n\n- Syntax: ``` g`` ```\n\nThe `g` tagged template will coerce inline grammar\n(in accordance to any global options).\n\n```ts\nimport { g } from \"gcomply\";\n\nlet views = content.viewCount,\n    shares = content.shareCount\n\nlet text = g`${views} new views, ${shares} new shares`\n// \"35 new views, 1 new share\"\n```\n\n### Complex grammar\n\n- Syntax: `inflect(text, options?)` \n\nThe `inflect()` function provides a little more flexibility for complex\ngrammatical agreement, and may also be passed additional external options:\n\n```ts\nimport { inflect } from \"gcomply\";\n\nlet text = \"Votre conseiller est prêt.\"\n\nlet opts = {\n    language: \"fr\",\n    morphology: { grammaticalGender: \"feminine\" }\n}\n\ninflect(text)        // \"Votre conseiller est prêt.\"\ninflect(text, opts)  // \"Votre conseillère est prête.\"\n```\n\n\u003e [!NOTE]\n\u003e **Terminology:**\n\u003e\n\u003e Parts of the API terminology is modeled to be consistent with the emerging equivalent\n\u003e Swift APIs for\n\u003e [morphology](https://developer.apple.com/documentation/foundation/morphology)\n\u003e and [inflection](https://developer.apple.com/videos/play/wwdc2023/10153/).\n\u003e\n\u003e Notably though, there is **no direct proxy** for Swift's\n\u003e [AttributedString](https://developer.apple.com/documentation/foundation/attributedstring)\n\u003e in JavaScript.\n\n## Implementation status\n\nThese are the Swift agreement features:\n\n| Status | Agreement Type | Methodology | Code Changes | Description\n| --- | ---------------------- | ----------------------- | ------------ | ---\n| partial | `inflect` | Proximity-based | No | Reference neighboring elements.\n| ❌ | `agreeWithArgument` | Explicit reference, same string | No | Directly reference other elements in the strings.\n| ❌ | `agreeWithConcept` | Explicit reference, injected | Yes | Agree with a `Concept` passed in via context.\n\n\u003e [!NOTE]\n\u003e **Source:** See [WWDC2023 @ 6:15](https://developer.apple.com/videos/play/wwdc2023/10153/)\n\n## 🛠️ Contributing\n\nContributions are welcome, such as:\n- New language packs\n- More granular inflection rules\n- Bug fixes and test cases\n- Integrations for other frameworks or i18n tools\n\n\u003e [!Important]\n\u003e Keep in mind, the goal of this package is not to provide perfect and comprehensive\n\u003e language support that covers all possible permutations out-of-the-box.\n\n\u003c!-- See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for details. --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freececomo%2Fgcomply","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freececomo%2Fgcomply","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freececomo%2Fgcomply/lists"}