cldr-grammatical-features 0.0.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025-Present Aviv Keller
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # cldr-grammatical-features
2
+
3
+ Tells which grammatical cases, genders and definiteness forms the nouns of
4
+ a language have, with the grammatical features of the
5
+ [Unicode CLDR](https://cldr.unicode.org/)
6
+ ([UTS #35](https://www.unicode.org/reports/tr35/tr35-general.html#Grammatical_Features)).
7
+ Translation and message formatting tools use it to know which forms of a
8
+ term a translator has to provide: four cases and three genders in German,
9
+ fourteen cases in Finnish, none in English.
10
+
11
+ ## Installation
12
+
13
+ ```sh
14
+ npm install cldr-grammatical-features
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ import { getGrammaticalFeatures } from "cldr-grammatical-features";
21
+
22
+ getGrammaticalFeatures("de");
23
+ // {
24
+ // cases: ["nominative", "genitive", "dative", "accusative"],
25
+ // genders: ["masculine", "feminine", "neuter"],
26
+ // definiteness: [],
27
+ // }
28
+
29
+ getGrammaticalFeatures("sv").definiteness; // ["definite", "indefinite"]
30
+ getGrammaticalFeatures("fi").cases.length; // 14
31
+ getGrammaticalFeatures("en"); // { cases: [], genders: [], definiteness: [] }
32
+ getGrammaticalFeatures("eo"); // undefined: no data
33
+ ```
34
+
35
+ The default export is `getGrammaticalFeatures`, with every export as a
36
+ property: `import getGrammaticalFeatures from "cldr-grammatical-features"`.
37
+
38
+ ## API
39
+
40
+ ### `getGrammaticalFeatures(locale)`
41
+
42
+ Returns `{ cases, genders, definiteness }` for the language of a BCP 47
43
+ language tag or `Intl.Locale`. Each is a list of CLDR's names for the
44
+ forms, empty if nouns do not vary that way. Returns `undefined` for the
45
+ languages that CLDR has no data for.
46
+
47
+ "Gender" stands for any noun class: the values include `"animate"`,
48
+ `"inanimate"`, `"personal"` and `"common"` besides `"masculine"`,
49
+ `"feminine"` and `"neuter"`.
50
+
51
+ ### `VERSION`
52
+
53
+ The CLDR version of the data, such as `"49.0.0"`.
54
+
55
+ ## License
56
+
57
+ MIT. Includes data from the Unicode CLDR, © Unicode, Inc., under the [Unicode License v3](https://www.unicode.org/license.txt).
package/index.d.mts ADDED
@@ -0,0 +1,33 @@
1
+ export declare const VERSION: string;
2
+ /**
3
+ * Returns the grammatical forms that the nouns of a language have
4
+ * @param {string | Intl.Locale} locale
5
+ * @returns {GrammaticalFeatures | undefined} undefined if CLDR has no data for the language
6
+ */
7
+ export declare function getGrammaticalFeatures(locale: string | Intl.Locale): GrammaticalFeatures | undefined;
8
+ declare const _default: typeof getGrammaticalFeatures & {
9
+ getGrammaticalFeatures: typeof getGrammaticalFeatures;
10
+ VERSION: string;
11
+ };
12
+ export type GrammaticalFeatures = {
13
+ /**
14
+ * e.g. ["nominative", "genitive", "dative", "accusative"]
15
+ */
16
+ cases: string[];
17
+ /**
18
+ * e.g. ["masculine", "feminine", "neuter"]
19
+ */
20
+ genders: string[];
21
+ /**
22
+ * e.g. ["definite", "indefinite"]
23
+ */
24
+ definiteness: string[];
25
+ };
26
+ /**
27
+ * Each list is empty if nouns do not vary that way
28
+ * @typedef {object} GrammaticalFeatures
29
+ * @property {string[]} cases e.g. ["nominative", "genitive", "dative", "accusative"]
30
+ * @property {string[]} genders e.g. ["masculine", "feminine", "neuter"]
31
+ * @property {string[]} definiteness e.g. ["definite", "indefinite"]
32
+ */
33
+ export { _default as default };
package/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ /*! cldr-grammatical-features | MIT License | Includes data © Unicode, Inc., Unicode License v3 (https://www.unicode.org/license.txt) */
2
+ const e=/* @__PURE__ */ new Map;function t(t){if(typeof t!=`string`)return new Intl.Locale(t).baseName;let n=e.get(t);return n===void 0&&(e.size>=1e3&&e.clear(),n=new Intl.Locale(t).baseName,e.set(t,n)),n}const n=/* @__PURE__ */ new Map([[`af`,[[],[],[]]],[`en`,[[],[],[]]],[`fil`,[[],[],[]]],[`ja`,[[],[],[]]],[`ko`,[[],[],[]]],[`lo`,[[],[],[]]],[`ms`,[[],[],[]]],[`my`,[[],[],[]]],[`ne`,[[],[],[]]],[`th`,[[],[],[]]],[`vi`,[[],[],[]]],[`zh`,[[],[],[]]],[`am`,[[0,1],[],[2,3]]],[`ar`,[[0,4,1],[5,6],[2,3,7]]],[`az`,[[0,4,8,1,9,10],[],[]]],[`ky`,[[0,4,8,1,9,10],[],[]]],[`uz`,[[0,4,8,1,9,10],[],[]]],[`bn`,[[0,1,4,10],[],[2,3]]],[`ca`,[[],[5,6],[]]],[`es`,[[],[5,6],[]]],[`fr`,[[],[5,6],[]]],[`it`,[[],[5,6],[]]],[`pt`,[[],[5,6],[]]],[`cs`,[[0,4,8,1,11,12,10],[13,14,6,15],[]]],[`sk`,[[0,4,8,1,11,12,10],[13,14,6,15],[]]],[`da`,[[0,4],[16,15],[2,3,17]]],[`de`,[[0,4,8,1],[5,6,15],[]]],[`el`,[[0,4,1,12],[5,6,15],[]]],[`fa`,[[],[],[2,3,7]]],[`fi`,[[0,18,9,19,20,21,22,23,4,24,25,11,26,27],[],[]]],[`gu`,[[0,4,1,8,10,11,12],[5,6,15],[]]],[`he`,[[],[5,6],[2,3,7]]],[`hi`,[[0,28],[5,6],[]]],[`pa`,[[0,28],[5,6],[]]],[`hr`,[[0,4,8,1,11,12,10],[13,14,6,15],[]]],[`sr`,[[0,4,8,1,11,12,10],[13,14,6,15],[]]],[`hu`,[[0,9,1,19,20,29,8,30,22,23,24,25,11,31,32,33,27],[],[]]],[`hy`,[[0,9,8,10,11],[],[]]],[`id`,[[],[],[2,3]]],[`is`,[[0,4,8,1],[5,6,15],[2,3]]],[`kk`,[[0,4,8,1,11,9,10],[],[]]],[`tr`,[[0,4,8,1,11,9,10],[],[]]],[`kn`,[[0,4,1,8,10,11,12],[5,6,15],[]]],[`lt`,[[0,4,8,1,11,12,10],[5,6],[]]],[`lv`,[[0,4,8,1,12,10],[5,6],[]]],[`ml`,[[0,4,8,1,11,10,21,34,35],[13,14,6,15],[]]],[`mr`,[[0,1,8,36,10,9,4],[5,6,15],[]]],[`nb`,[[0,4],[5,6,15],[2,3]]],[`nn`,[[0,4],[5,6,15],[2,3]]],[`no`,[[0,4],[5,6,15],[2,3]]],[`nl`,[[],[16,15],[]]],[`pl`,[[0,4,8,1,11,12,10],[13,14,37,6,15],[]]],[`ro`,[[0,4],[5,6,15],[2,3]]],[`ru`,[[0,4,8,1,11,38,12,10],[5,6,15],[]]],[`si`,[[0,4,9,1,8],[5,6,15],[2,3]]],[`sl`,[[0,4,1,8,11,10],[5,6,15],[]]],[`sv`,[[0,4],[16,15],[2,3]]],[`ta`,[[0,4,1,8,10,11,9,12],[],[]]],[`te`,[[0,28,1,8,10,11],[],[]]],[`uk`,[[0,4,8,1,11,12,10],[5,6,15],[]]],[`ur`,[[0,28],[5,6],[]]]]),r=/* @__PURE__ */ `nominative accusative definite indefinite genitive masculine feminine construct dative ablative locative instrumental vocative animate inanimate neuter common unspecified abessive adessive allative comitative elative essive illative inessive partitive translative oblique causal delative sublative superessive terminative locativecopulative sociative ergative personal prepositional`.split(` `),i=`49.0.0`;function a(e){let i=n.get(t(e).split(`-`)[0]);if(i===void 0)return;let[a,o,s]=i.map(e=>e.map(e=>r[e]));return{cases:a,genders:o,definiteness:s}}var o=/* @__PURE__ */ Object.assign(a,{getGrammaticalFeatures:a,VERSION:i});export{i as VERSION,o as default,a as getGrammaticalFeatures};
package/package.json CHANGED
@@ -1 +1,42 @@
1
- {"name":"cldr-grammatical-features","version":"0.0.0","description":"Placeholder for trusted publishing","license":"MIT"}
1
+ {
2
+ "name": "cldr-grammatical-features",
3
+ "version": "1.0.0",
4
+ "description": "Find the grammatical cases, genders and definiteness forms that the nouns of a language have, for translation and message formatting tools, based on the Unicode CLDR",
5
+ "keywords": [
6
+ "unicode",
7
+ "cldr",
8
+ "grammar",
9
+ "grammatical-case",
10
+ "grammatical-gender",
11
+ "definiteness",
12
+ "inflection",
13
+ "messageformat",
14
+ "i18n",
15
+ "locale"
16
+ ],
17
+ "license": "MIT",
18
+ "author": "Aviv Keller <me@aviv.sh>",
19
+ "type": "module",
20
+ "main": "./index.mjs",
21
+ "types": "./index.d.mts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./index.d.mts",
25
+ "default": "./index.mjs"
26
+ }
27
+ },
28
+ "files": [
29
+ "index.mjs",
30
+ "index.d.mts"
31
+ ],
32
+ "sideEffects": false,
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/avivkeller/unicode-packages.git",
36
+ "directory": "packages/cldr/grammatical-features"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/avivkeller/unicode-packages/issues"
40
+ },
41
+ "homepage": "https://github.com/avivkeller/unicode-packages/tree/main/packages/cldr/grammatical-features#readme"
42
+ }