genshin-text 4.4.0 → 4.6.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/README.md CHANGED
@@ -5,9 +5,7 @@
5
5
  [![NPM downloads][badge-npm-downloads]][url-npm]
6
6
  [![NPM Unpacked Size (with version)][badge-npm-unpacked-size]][url-npm]
7
7
 
8
- Genshin Impact's own text in its fifteen languages, as an unofficial, non-commercial fan work and not affiliated with HoYoverse.
9
-
10
- Nothing is translated by hand: each string is the game's own, in the game's own translation.
8
+ Genshin Impact's own text in its fifteen languages, none translated by hand. It is an unofficial, non-commercial fan work, not affiliated with HoYoverse.
11
9
 
12
10
  Design notes live in [the specs](https://github.com/Esposter/Esposter/tree/main/openspec/specs/genshin/game-text).
13
11
 
@@ -25,7 +23,9 @@ Design notes live in [the specs](https://github.com/Esposter/Esposter/tree/main/
25
23
  pnpm i genshin-text
26
24
  ```
27
25
 
28
- Pick the reader's language, load its text once, and index it by key:
26
+ 1. Pick the reader's language with `matchGameLanguage`. Pass in the browser's language list.
27
+ 2. Load that language's text once with `GameTextLoaderMap`.
28
+ 3. Index the text with a `GameTextKey` value.
29
29
 
30
30
  ```ts
31
31
  import { GameTextKey, GameTextLoaderMap, matchGameLanguage } from "genshin-text";
@@ -35,20 +35,22 @@ const gameText = await GameTextLoaderMap[language]();
35
35
  console.log(gameText[GameTextKey.Loading]);
36
36
  ```
37
37
 
38
+ Check: the console shows the loading string in the reader's language, or in English when no language of the fifteen matches.
39
+
38
40
  ## <a name="key-exports">🧩 Key Exports</a>
39
41
 
40
- | Export | Kind | Purpose |
41
- | ------------------------ | --------- | ---------------------------------------------------------------------------------------------- |
42
- | `fillGameTextValues` | function | Fills a string's numbered placeholders with the values given, keeping any with no value |
43
- | `GameLanguage` | enum | The fifteen languages the game is written in |
44
- | `GameText` | type | Every referenced string in one language, keyed by `GameTextKey` |
45
- | `GameTextKey` | enum | Every string a consumer shows, by the game's own text id |
46
- | `GameTextLoaderMap` | const | Loads one language's `GameText`: English bundled, every other language a chunk on first use |
47
- | `GameTextSegment` | interface | A run of a game string under one colour, or plain when it has none |
48
- | `getAcceptLanguageTags` | function | The tags of an `Accept-Language` header, most preferred first, weighed by their `q` |
49
- | `getLanguageDisplayName` | function | A game language's name as written in another game language, or as given when either is not one |
50
- | `matchGameLanguage` | function | The game language nearest a list of preferred tags, English when none matches |
51
- | `splitGameTextColors` | function | Splits a game string into plain runs and colour-tagged runs |
42
+ | Export | Kind | Purpose |
43
+ | ------------------------ | --------- | -------------------------------------------------------------------------------------------------------------------- |
44
+ | `fillGameTextValues` | function | Fills a string's numbered placeholders with the values given, and keeps each placeholder that has no value |
45
+ | `GameLanguage` | enum | The fifteen languages of the game |
46
+ | `GameText` | type | Every referenced string in one language, keyed by `GameTextKey` |
47
+ | `GameTextKey` | enum | Every string that a consumer shows, by the game's own text id |
48
+ | `GameTextLoaderMap` | const | Loads one language's `GameText`: English is bundled, and each other language is a chunk loaded on first use |
49
+ | `GameTextSegment` | interface | A run of a game string under one colour, or plain when it has none |
50
+ | `getAcceptLanguageTags` | function | The tags of an `Accept-Language` header, most preferred first, weighed by their `q` |
51
+ | `getLanguageDisplayName` | function | A game language's name, as written in another game language, or the name as given when either is not a game language |
52
+ | `matchGameLanguage` | function | The game language nearest to a list of preferred tags, or English when none matches |
53
+ | `splitGameTextColors` | function | Splits a game string into plain runs and colour-tagged runs |
52
54
 
53
55
  ## <a name="license">⚖️ License</a>
54
56