Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ Document 文檔: https://byvoid.github.io/OpenCC/
* `jp2t.json` New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai) 日文新字體到繁體(OpenCC 標準,舊字體)
* `tw2t.json` Traditional Chinese (Taiwan standard) to Traditional Chinese 臺灣正體到繁體(OpenCC 標準)

#### 指定配置文件

通过环境变量`OPENCC_DATA_DIR`加载指定路径下的配置文件
```sh
OPENCC_DATA_DIR=/path/to/your/config/dir opencc --help
```

## Build 編譯

### Build with CMake
Expand Down
9 changes: 9 additions & 0 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ class ConfigInternal {
}
}

const char* envPath = std::getenv("OPENCC_DATA_DIR");
if (envPath != nullptr) {
auto path = std::string(envPath) + '/' + fileName;
ifs.open(UTF8Util::GetPlatformString(path).c_str());
if (ifs.is_open()) {
return path;
}
}

throw FileNotFound(fileName);
}
};
Expand Down
Loading