cldr-grammatical-features 0.0.0 → 1.0.1
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 +7 -0
- package/README.md +57 -0
- package/index.d.mts +33 -0
- package/index.mjs +2 -0
- package/package.json +42 -1
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=[[],[],[]],r=[2,3],i=[5,6],a=[[0,4,8,1,9,10],[],[]],o=[[],i,[]],s=[0,4,8,1,11,12,10],c=[13,14,6,15],l=[s,c,[]],u=[5,6,15],d=[[0,4,1,8,10,11,12],u,[]],f=[[0,28],i,[]],p=[[0,4,8,1,11,9,10],[],[]],m=[[0,4],u,r],h=/* @__PURE__ */ new Map([[`af`,n],[`en`,n],[`fil`,n],[`ja`,n],[`ko`,n],[`lo`,n],[`ms`,n],[`my`,n],[`ne`,n],[`th`,n],[`vi`,n],[`zh`,n],[`am`,[[0,1],[],r]],[`ar`,[[0,4,1],i,[2,3,7]]],[`az`,a],[`ky`,a],[`uz`,a],[`bn`,[[0,1,4,10],[],r]],[`ca`,o],[`es`,o],[`fr`,o],[`it`,o],[`pt`,o],[`cs`,l],[`sk`,l],[`da`,[[0,4],[16,15],[2,3,17]]],[`de`,[[0,4,8,1],u,[]]],[`el`,[[0,4,1,12],u,[]]],[`fa`,[[],[],[2,3,7]]],[`fi`,[[0,18,9,19,20,21,22,23,4,24,25,11,26,27],[],[]]],[`gu`,d],[`he`,[[],i,[2,3,7]]],[`hi`,f],[`pa`,f],[`hr`,l],[`sr`,l],[`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`,[[],[],r]],[`is`,[[0,4,8,1],u,r]],[`kk`,p],[`tr`,p],[`kn`,d],[`lt`,[s,i,[]]],[`lv`,[[0,4,8,1,12,10],i,[]]],[`ml`,[[0,4,8,1,11,10,21,34,35],c,[]]],[`mr`,[[0,1,8,36,10,9,4],u,[]]],[`nb`,m],[`nn`,m],[`no`,m],[`nl`,[[],[16,15],[]]],[`pl`,[s,[13,14,37,6,15],[]]],[`ro`,m],[`ru`,[[0,4,8,1,11,38,12,10],u,[]]],[`si`,[[0,4,9,1,8],u,r]],[`sl`,[[0,4,1,8,11,10],u,[]]],[`sv`,[[0,4],[16,15],r]],[`ta`,[[0,4,1,8,10,11,9,12],[],[]]],[`te`,[[0,28,1,8,10,11],[],[]]],[`uk`,[s,u,[]]],[`ur`,f]]),g=/* @__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(` `),_=`49.0.0`;function v(e){let n=h.get(t(e).split(`-`)[0]);if(n===void 0)return;let[r,i,a]=n.map(e=>e.map(e=>g[e]));return{cases:r,genders:i,definiteness:a}}var y=/* @__PURE__ */ Object.assign(v,{getGrammaticalFeatures:v,VERSION:_});export{_ as VERSION,y as default,v as getGrammaticalFeatures};
|
package/package.json
CHANGED
|
@@ -1 +1,42 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "cldr-grammatical-features",
|
|
3
|
+
"version": "1.0.1",
|
|
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
|
+
}
|