{"id":22218565,"url":"https://github.com/megahertz/js-simple-plurals","last_synced_at":"2025-07-26T23:36:24.318Z","repository":{"id":57283630,"uuid":"50637907","full_name":"megahertz/js-simple-plurals","owner":"megahertz","description":"Just a set of plural functions for different languages","archived":false,"fork":false,"pushed_at":"2016-01-29T04:47:10.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T19:55:25.434Z","etag":null,"topics":[],"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/megahertz.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}},"created_at":"2016-01-29T04:42:02.000Z","updated_at":"2016-01-29T04:43:26.000Z","dependencies_parsed_at":"2022-08-31T00:00:13.535Z","dependency_job_id":null,"html_url":"https://github.com/megahertz/js-simple-plurals","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fjs-simple-plurals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fjs-simple-plurals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fjs-simple-plurals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fjs-simple-plurals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/megahertz","download_url":"https://codeload.github.com/megahertz/js-simple-plurals/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245415609,"owners_count":20611577,"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":[],"created_at":"2024-12-02T22:27:09.425Z","updated_at":"2025-03-25T07:22:52.479Z","avatar_url":"https://github.com/megahertz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-simple-plurals\nJust a set of plural functions for different languages\n\n# Installation\n\n#### Install with Bower\n```sh\n$ bower install js-simple-plurals\n```\n\n#### Install with NPM\n\n```sh\n$ npm install js-simple-plurals\n```\n\n# Examples\n\n#### Node.js\n```js\nvar plural = require('./node/en');\nfunction pluralizeEn(number, one, many) {\n    var rules = [one, many];\n    var position = plural(number);\n    return rules[position];\n}\n\nconsole.log('2 ' + pluralizeEn(2, 'day', 'days')); // prints '2 days'\n```\n\n#### Web\n```html\n\u003cform\u003e\n    \u003clabel\u003e\n        Number\n        \u003cinput type=\"number\" id=\"number\" value=\"1\"\u003e\n    \u003c/label\u003e\n    \u003cdiv id=\"text\"\u003e\u003c/div\u003e\n\u003c/form\u003e\n\n\u003cscript src=\"web/en.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    var number = document.getElementById('number');\n    var text   = document.getElementById('text');\n\n    function pluralizeEn(number, one, many) {\n        var rules = [one, many];\n        var position = plural.en(number);\n        return rules[position];\n    }\n\n    function updateText() {\n        var content = number.value + ': ' + pluralizeEn(\n            number.value,\n            'day',\n            'days'\n        );\n        document.getElementById('text').textContent = content;\n    }\n\n    document.getElementById('number').addEventListener('change', updateText);\n    updateText();\n\u003c/script\u003e\n```\n\n## About\nPlural rules follow the guideline found in the Unicode CLDR Charts on [Language Plural Rules](http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html).\nThis plural rules are based on rules generated by [universal-i18n](https://github.com/yanickrochon/universal-i18n/).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegahertz%2Fjs-simple-plurals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegahertz%2Fjs-simple-plurals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegahertz%2Fjs-simple-plurals/lists"}