Skip to content

Commit 24fa870

Browse files
committed
Basic translation substitution via the ForEachString api
1 parent d2fb883 commit 24fa870

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/translation.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <iomanip>
2525
#include <tinygettext/po_parser.hpp>
2626
#include <tinygettext/log.hpp>
27+
#include <lcf/data.h>
28+
#include <lcf/rpg/terms.h>
2729

2830
#include "game_map.h"
2931
#include "pending_message.h"
@@ -269,10 +271,18 @@ void Translation::SelectTranslation(const std::string& langId)
269271
Output::Debug("Translation loaded {} sys, {} common, {} battle, and {} map .po files", (sys==nullptr?0:1), (battle==nullptr?0:1), (common==nullptr?0:1), maps.size());
270272
}
271273

274+
//
275+
// TODO: Right now "key" will be something like "end_game", and the "context" is "term"
276+
// Does that make sense? Do we also want to pass in the context from the auto-generator.
272277
void Translation::RewriteDatabase()
273278
{
274-
std::cout <<"REWRITE...\n";
275-
279+
// Translate all terms
280+
lcf::Data::terms.ForEachString([this](const std::string& value, const std::string& name)->std::string {
281+
if (sys!=nullptr) {
282+
return sys->translate_ctxt("term", value);
283+
}
284+
return value;
285+
});
276286
}
277287

278288

@@ -298,6 +308,7 @@ void Translation::ClearTranslation()
298308

299309
std::string Translation::translate_sys(const std::string& ctxt, const std::string& id) const
300310
{
311+
if (ctxt == "term") { return id; } // TEMP
301312
if (sys!=nullptr) {
302313
return sys->translate_ctxt(ctxt, id);
303314
}

0 commit comments

Comments
 (0)