@ethnolib/find-language 0.1.2 → 0.1.4

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.
@@ -0,0 +1,78 @@
1
+ import { ILanguage, IScript, LanguageType } from './findLanguageInterfaces';
2
+ export declare const COMMA_SEPARATOR = ", ";
3
+ export interface ILanguageInternal {
4
+ autonym: string;
5
+ exonym: string;
6
+ iso639_3_code: string;
7
+ languageSubtag: string;
8
+ regionNames: Set<string>;
9
+ names: Set<string>;
10
+ scripts: {
11
+ [key: string]: IScript;
12
+ };
13
+ alternativeTags: Set<string>;
14
+ isRepresentativeForMacrolanguage: boolean;
15
+ isMacrolanguage: boolean;
16
+ parentMacrolanguage?: ILanguage;
17
+ languageType: LanguageType;
18
+ }
19
+ export interface ILangtagsJsonEntryInternal {
20
+ full: string;
21
+ iso639_3: string;
22
+ iana: string[];
23
+ latnnames: string[];
24
+ localname: string;
25
+ localnames: string[];
26
+ macrolang: string;
27
+ name: string;
28
+ names: string[];
29
+ nophonvars: boolean;
30
+ obsolete: boolean;
31
+ region: string;
32
+ regions: string[];
33
+ regionname: string;
34
+ rod: string;
35
+ script: string;
36
+ sldr: string;
37
+ supress: boolean;
38
+ tag: string;
39
+ tags: string[];
40
+ unwritten: boolean;
41
+ variants: string[];
42
+ windows: string;
43
+ isRepresentativeForMacrolanguage: boolean;
44
+ }
45
+ interface IIsoCodeDetailsInternal {
46
+ isMacrolanguage: boolean;
47
+ languageType: LanguageType;
48
+ iso639_3Code: string;
49
+ iso639_1Code: string;
50
+ name: string;
51
+ }
52
+ export declare const scriptNames: {
53
+ [key: string]: string;
54
+ };
55
+ export declare const isoCodesDetails: {
56
+ [key: string]: IIsoCodeDetailsInternal;
57
+ };
58
+ export declare const iso639_1To639_3: {
59
+ [key: string]: string;
60
+ };
61
+ export declare const indivlangsToMacrolangs: {
62
+ [key: string]: string;
63
+ };
64
+ export declare const macrolangsToRepresentativeLangs: {
65
+ [key: string]: string;
66
+ };
67
+ export declare const macrolanguagesByCode: {
68
+ [key: string]: ILanguage;
69
+ };
70
+ export declare function getLanguageType(iso639_3: string): LanguageType;
71
+ export declare function isMacrolanguage(iso639_3: string): boolean;
72
+ export declare function defaultScriptForLanguage(languageTag: string, language?: ILanguage): IScript | undefined;
73
+ export declare function getAllPossibleNames(entry: ILangtagsJsonEntryInternal): Set<string>;
74
+ export declare function uncomma(str: string | undefined): string | undefined;
75
+ export declare function uncommaAll(strs: Set<string>): Set<string>;
76
+ export declare function stripMacrolanguageParenthetical(languageName: string): string;
77
+ export declare function stripMacrolanguageParentheticalFromAll(names: Set<string>): Set<string>;
78
+ export {};
@@ -1,3 +1,4 @@
1
+ import { ILanguage, IOrthography, IRegion, IScript } from './findLanguageInterfaces';
1
2
  export declare function getShortestSufficientLangtag(langtag: string): string | undefined;
2
3
  export declare function getMaximalLangtag(langtag: string): string | undefined;
3
4
  export declare function createTag({ languageCode, scriptCode, regionCode, dialectCode, }: {
@@ -6,3 +7,24 @@ export declare function createTag({ languageCode, scriptCode, regionCode, dialec
6
7
  regionCode?: string;
7
8
  dialectCode?: string;
8
9
  }): string;
10
+ export declare function codeMatches(code1: string | undefined, code2: string | undefined): boolean;
11
+ export declare const UNLISTED_LANGUAGE: ILanguage;
12
+ export declare function isUnlistedLanguage(selectedLanguage: ILanguage | undefined): boolean;
13
+ export declare function languageForManuallyEnteredTag(manuallyEnteredTag: string): ILanguage;
14
+ export declare function isManuallyEnteredTagLanguage(selectedLanguage: ILanguage | undefined): boolean;
15
+ export declare function isValidBcp47Tag(tag: string | undefined): boolean;
16
+ interface ITagParts {
17
+ languageSubtag: string | undefined;
18
+ scriptSubtag: string | undefined;
19
+ regionSubtag: string | undefined;
20
+ variantSubtag?: string;
21
+ privateUseSubtag?: string;
22
+ otherSubtags?: string[];
23
+ }
24
+ export declare function splitTag(tag: string): ITagParts;
25
+ export declare function parseLangtagFromLangChooser(languageTag: string, // must be the default language subtag for the language
26
+ searchResultModifier?: (results: ILanguage[], searchString: string) => ILanguage[]): IOrthography | undefined;
27
+ export declare function defaultRegionForLangTag(languageTag: string): IRegion | undefined;
28
+ export declare function createTagFromOrthography(orthography: IOrthography): string;
29
+ export declare function defaultDisplayName(language?: ILanguage, script?: IScript): string | undefined;
30
+ export {};
@@ -1,7 +1,7 @@
1
- import { FuseResult } from 'fuse.js';
2
1
  import { ILanguage } from './findLanguageInterfaces';
3
2
  export declare const START_OF_MATCH_MARKER = "[";
4
3
  export declare const END_OF_MATCH_MARKER = "]";
5
- export declare function demarcateResults(results: FuseResult<ILanguage>[]): FuseResult<ILanguage>[];
4
+ export declare const TEMPORARY_SEPARATOR = "###";
5
+ export declare function demarcateResults(results: ILanguage[], searchString: string): ILanguage[];
6
6
  export declare function stripDemarcation(demarcatedText: string | undefined): string | undefined;
7
7
  export declare function deepStripDemarcation<T>(demarcated: T): T;
package/package.json CHANGED
@@ -3,11 +3,12 @@
3
3
  "description": "A library for fuzzy-searching for languages and other utils for language choosers",
4
4
  "author": "SIL Global",
5
5
  "license": "MIT",
6
- "version": "0.1.2",
6
+ "version": "0.1.4",
7
7
  "main": "./index.js",
8
8
  "types": "./index.d.ts",
9
9
  "scripts": {
10
10
  "langtag-processing": "tsx ./langtagProcessing.ts",
11
+ "prebuild": "npm run langtag-processing",
11
12
  "build": "nx vite:build",
12
13
  "typecheck": "tsc",
13
14
  "test": "nx vite:test --config vitest.config.ts",
@@ -23,9 +24,5 @@
23
24
  "@types/node": "^20.16.11",
24
25
  "tsx": "^4.19.2",
25
26
  "typescript": "^5.2.2"
26
- },
27
- "// We've tested with 18 and have no reason to believe it won't work with higher versions": "",
28
- "engines": {
29
- "node": ">=18.18"
30
27
  }
31
28
  }
@@ -2,4 +2,4 @@ import { ILanguage, IRegion, IScript } from './findLanguageInterfaces';
2
2
  export declare function getAllRegions(): IRegion[];
3
3
  export declare function getRegionBySubtag(code: string): IRegion | undefined;
4
4
  export declare function getAllScripts(): IScript[];
5
- export declare function getScriptForLanguage(scriptCode: string, language: ILanguage): IScript | undefined;
5
+ export declare function getScriptForLanguage(scriptCode: string, language?: ILanguage): IScript | undefined;
@@ -1,5 +1,5 @@
1
- import { FuseResult } from 'fuse.js';
2
1
  import { ILanguage } from './findLanguageInterfaces';
3
2
  export declare const fieldsToSearch: string[];
4
- export declare function searchForLanguage(queryString: string): FuseResult<ILanguage>[];
5
- export declare function getLanguageBySubtag(code: string, searchResultModifier?: (results: FuseResult<ILanguage>[], searchString: string) => ILanguage[]): ILanguage | undefined;
3
+ export declare function asyncSearchForLanguage(queryString: string, appendResults: (results: ILanguage[], forSearchString: string) => boolean): Promise<void>;
4
+ export declare function asyncGetAllLanguageResults(searchString: string): Promise<ILanguage[]>;
5
+ export declare function getLanguageBySubtag(code: string, searchResultModifier?: (results: ILanguage[], searchString: string) => ILanguage[]): ILanguage | undefined;
@@ -1,11 +1,8 @@
1
- import { FuseResult } from 'fuse.js';
2
1
  import { ILanguage, IScript } from './findLanguageInterfaces';
3
- export declare function stripResultMetadata(results: FuseResult<ILanguage>[]): ILanguage[];
4
2
  export declare function filterScripts(scriptFilter: (value: IScript) => boolean, results: ILanguage[]): ILanguage[];
5
3
  export declare function modifyScripts(scriptModifier: (value: IScript) => IScript, results: ILanguage[]): ILanguage[];
6
4
  export declare function rawIsoCode(result: ILanguage): string | undefined;
7
- export declare function codeMatches(code1: string | undefined, code2: string | undefined): boolean;
8
5
  export declare function substituteInModifiedEntry(targetCode: string, getModifiedEntry: (result: ILanguage) => ILanguage, results: ILanguage[]): ILanguage[];
9
6
  export declare function filterOnLanguageCode(langCodeFilter: (value: string) => boolean, results: ILanguage[]): ILanguage[];
10
7
  export declare function prioritizeLangByKeywords(keywords: string[], searchString: string, langCodeToPrioritize: string, results: ILanguage[]): ILanguage[];
11
- export declare function defaultSearchResultModifier(results: FuseResult<ILanguage>[], searchString: string): ILanguage[];
8
+ export declare function defaultSearchResultModifier(results: ILanguage[], searchString: string): ILanguage[];
package/testUtils.d.ts CHANGED
@@ -4,7 +4,8 @@ interface ILanguageTestEntry {
4
4
  exonym?: string;
5
5
  iso639_3_code?: string;
6
6
  languageSubtag?: string;
7
- regionNames?: string;
7
+ regionNamesForDisplay?: string;
8
+ regionNamesForSearch?: string[];
8
9
  names?: string[];
9
10
  scripts?: IScript[];
10
11
  variants?: string;