mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-18 03:21:27 +02:00
enable translation for vcmp
This commit is contained in:
parent
b16f721b39
commit
772224e46c
@ -127,14 +127,19 @@ static std::string convertMapName(std::string input)
|
||||
|
||||
std::string CampaignHandler::readLocalizedString(CampaignHeader & target, CBinaryReader & reader, std::string filename, std::string modName, std::string encoding, std::string identifier)
|
||||
{
|
||||
TextIdentifier stringID( "campaign", convertMapName(filename), identifier);
|
||||
|
||||
std::string input = TextOperations::toUnicode(reader.readBaseString(), encoding);
|
||||
|
||||
if (input.empty())
|
||||
return readLocalizedString(target, input, filename, modName, identifier);
|
||||
}
|
||||
|
||||
std::string CampaignHandler::readLocalizedString(CampaignHeader & target, std::string text, std::string filename, std::string modName, std::string identifier)
|
||||
{
|
||||
TextIdentifier stringID( "campaign", convertMapName(filename), identifier);
|
||||
|
||||
if (text.empty())
|
||||
return "";
|
||||
|
||||
target.getTexts().registerString(modName, stringID, input);
|
||||
target.getTexts().registerString(modName, stringID, text);
|
||||
return stringID.get();
|
||||
}
|
||||
|
||||
@ -150,8 +155,8 @@ void CampaignHandler::readHeaderFromJson(CampaignHeader & ret, JsonNode & reader
|
||||
ret.version = CampaignVersion::VCMI;
|
||||
ret.campaignRegions = CampaignRegions::fromJson(reader["regions"]);
|
||||
ret.numberOfScenarios = reader["scenarios"].Vector().size();
|
||||
ret.name.appendTextID(reader["name"].String());
|
||||
ret.description.appendTextID(reader["description"].String());
|
||||
ret.name.appendTextID(readLocalizedString(ret, reader["name"].String(), filename, modName, "name"));
|
||||
ret.description.appendTextID(readLocalizedString(ret, reader["description"].String(), filename, modName, "name"));
|
||||
ret.author.appendRawString(reader["author"].String());
|
||||
ret.authorContact.appendRawString(reader["authorContact"].String());
|
||||
ret.campaignVersion.appendRawString(reader["campaignVersion"].String());
|
||||
|
@ -17,6 +17,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
class DLL_LINKAGE CampaignHandler
|
||||
{
|
||||
static std::string readLocalizedString(CampaignHeader & target, CBinaryReader & reader, std::string filename, std::string modName, std::string encoding, std::string identifier);
|
||||
static std::string readLocalizedString(CampaignHeader & target, std::string text, std::string filename, std::string modName, std::string identifier);
|
||||
|
||||
static void readCampaign(Campaign * target, const std::vector<ui8> & stream, std::string filename, std::string modName, std::string encoding);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user