Resource icon

源码 [LiteLoader C++] 仿MC原版的LL语言文件及读取头文件 1

版权类型
原创
版权链接
#
下载密码:LLLL

目前的状态是基本能用,读个原版语言文件没多大问题

支持#注释,4个以内的%n匹配(原版最多是3)

对语言文件(.lang)的格式有要求,请在附赠的MC原版语言包的基础上更改

【使用指南】

  1. 把头文件扔进项目
  2. 包含头文件
  3. 如下:
C++:
//// 加载 ////
string languageName = "zh_CN";
std::ifstream languageFile;
languageFile.open("plugins/Wheat/texts/" + languageName + ".lang");
if (!lang.load(&languageFile)) logger.warn("languageFile load failed.");
languageFile.close();

//// 读取 ////
// 给定键名读取
lang["tpw.info.worldNotFound"]  // 未找到世界
// 给定键名和四个以内的替换字符,获取拼接后的字符串
lang.transform("tpw.info.teleporting.user", "CometWind", "SC") // 将CometWind传送到SC
对应的语言文件:
INI:
# 一行注释
tpw.info.teleporting.user=将%1名玩家传送到%2...# 尾随注释
tpw.info.worldNotFound=未找到世界

虽然看起来很有问题,但这行会被自动忽略
(于是成功的氵了一贴)
Author
cometwind
Downloads
345
Views
890
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from cometwind

Share this resource

Back
Top Bottom