|
1 | 1 | # opencc-data [](https://www.npmjs.com/package/opencc-data) [](https://www.jsdelivr.com/package/npm/opencc-data) |
2 | 2 |
|
3 | | -A collection of word lists for Simplified and Traditional Chinese conversions from the [OpenCC](https://github.com/BYVoid/OpenCC) project. |
| 3 | +[繁體中文](README.zh-TW.md) |
| 4 | + |
| 5 | +A collection of dictionary data, configs, and test data for Simplified and Traditional Chinese conversions from the [OpenCC](https://github.com/BYVoid/OpenCC) project. |
4 | 6 |
|
5 | 7 | ## Compatibility |
6 | 8 |
|
7 | | -This project is primarily maintained for use with [opencc-js](https://github.com/nk2028/opencc-js). |
| 9 | +This package is intended for [opencc-js](https://github.com/nk2028/opencc-js) and other OpenCC-compatible implementations that consume OpenCC dictionary and config data. |
8 | 10 |
|
9 | 11 | - **Strict Version Matching**: Compatibility is only guaranteed when the version of `opencc-data` strictly matches the version of the consumer package. |
10 | 12 | - **Breaking Changes**: We do not guarantee compatibility between different versions of `opencc-data`. Structure or file names may change to align with upstream OpenCC updates. |
11 | 13 |
|
12 | 14 | ## Data Sync Policy |
13 | 15 |
|
14 | | -This package syncs upstream OpenCC dictionary `.txt` files, config `.json` files, and `test/testcases/testcases.json`. It also generates and checks in derived dictionaries during data sync: `TSCharactersExt.txt` from `TSCharacters.txt`, plus the reverse variant dictionaries `HKVariantsRev.txt`, `TWVariantsRev.txt`, and `JPVariantsRev.txt` from their corresponding variant dictionaries. |
| 16 | +This package syncs dictionary `.txt` files and config `.json` files from OpenCC's generated resource zip, plus `test/testcases/testcases.json` from the upstream repository. Each sync keeps the upstream resource manifest as an internal baseline so future updates can detect substantive data changes by resource hash. |
15 | 17 |
|
16 | 18 | ## Usage |
17 | 19 |
|
18 | | -The data files prioritize canonical data from the OpenCC project. The following configurations are strictly consistent with the logic in OpenCC's `.json` configuration files: |
19 | | - |
20 | | -- **Outer Array (Stages)**: Represents the conversion-chain stages. |
21 | | -- **Inner Array (Groups)**: Represents a dictionary group used within one stage; dictionaries earlier in the group have higher priority when their entries overlap (merged relationship). |
22 | | - |
23 | | -**From Chinese variants to OpenCC standard:** |
24 | | - |
25 | | -```json |
26 | | -{ |
27 | | - "cn": [["STPhrases", "STCharacters"]], |
28 | | - "hk": [["HKVariantsRevPhrases", "HKVariantsRev"]], |
29 | | - "tw": [["TWVariantsRevPhrases", "TWVariantsRev"]], |
30 | | - "twp": [["TWPhrasesRev", "TWVariantsRevPhrases", "TWVariantsRev"]], |
31 | | - "jp": [["JPShinjitaiPhrases", "JPShinjitaiCharacters", "JPVariantsRev"]] |
32 | | -} |
33 | | -``` |
34 | | - |
35 | | -**From OpenCC standard to Chinese variants:** |
36 | | - |
37 | | -```json |
38 | | -{ |
39 | | - "cn": [["TSPhrases", "TSCharactersExt", "TSCharacters"]], |
40 | | - "hk": [["HKVariantsPhrases", "HKVariants"]], |
41 | | - "tw": [["TWVariantsPhrases", "TWVariants"]], |
42 | | - "twp": [["TWPhrases"], ["TWVariantsPhrases", "TWVariants"]], |
43 | | - "jp": [["JPVariants"]] |
44 | | -} |
45 | | -``` |
46 | | - |
47 | | -`TSCharactersExt` contains rare inferred simplified forms that may render as tofu (missing glyph boxes) in common fonts. It should generally be omitted unless those extended mappings are explicitly required. |
48 | | - |
49 | | -**Explanation of the Chinese variants above:** |
| 20 | +Use the config files shipped in `data/config/` as the source of truth for dictionary order and conversion-chain behavior. Config contents can change between OpenCC versions, so consumers should load the matching config file for the package version they depend on instead of hard-coding dictionary lists from this README. |
50 | 21 |
|
51 | | -- `cn`: Simplified Chinese (Mainland China) |
52 | | -- `tw`: Traditional Chinese (Taiwan) |
53 | | -- `twp`: Traditional Chinese (Taiwan, with phrase conversion) |
54 | | -- `hk`: Traditional Chinese (Hong Kong) |
55 | | -- `jp`: Japanese Shinjitai |
| 22 | +Dictionary text files are shipped in `data/`. Config files reference those dictionaries by file name and preserve OpenCC's stage/group ordering semantics. |
0 commit comments