mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Support localize entries that have a name that cannot be represented as an identifier
This commit is contained in:
parent
cf711c3af7
commit
36cd9e11fe
@ -8,7 +8,10 @@ SequenceLocalizeFileReference::SequenceLocalizeFileReference()
|
||||
|
||||
AddMatchers({
|
||||
create.Keyword("REFERENCE"),
|
||||
create.Identifier().Capture(CAPTURE_REFERENCE_NAME),
|
||||
create.Or({
|
||||
create.Identifier(),
|
||||
create.String()
|
||||
}).Capture(CAPTURE_REFERENCE_NAME),
|
||||
create.Type(SimpleParserValueType::NEW_LINE)
|
||||
});
|
||||
}
|
||||
|
@ -38,13 +38,27 @@ void StringFileDumper::WriteHeader()
|
||||
m_wrote_header = true;
|
||||
}
|
||||
|
||||
void StringFileDumper::WriteReference(const std::string& reference) const
|
||||
{
|
||||
if (reference.find_first_not_of(utils::LETTERS_AL_NUM_UNDERSCORE) != std::string::npos)
|
||||
{
|
||||
m_stream << "REFERENCE \"";
|
||||
|
||||
utils::EscapeStringForQuotationMarks(m_stream, reference);
|
||||
|
||||
m_stream << "\"\n";
|
||||
}
|
||||
else
|
||||
m_stream << "REFERENCE " << reference << "\n";
|
||||
}
|
||||
|
||||
void StringFileDumper::WriteLocalizeEntry(const std::string& reference, const std::string& value)
|
||||
{
|
||||
if (!m_wrote_header)
|
||||
WriteHeader();
|
||||
|
||||
m_stream << "\n";
|
||||
m_stream << "REFERENCE " << reference << "\n";
|
||||
WriteReference(reference);
|
||||
|
||||
const auto valueSpacing = std::string(15 - m_language_caps.length(), ' ');
|
||||
m_stream << "LANG_" << m_language_caps << valueSpacing << "\"";
|
||||
|
@ -14,6 +14,7 @@ class StringFileDumper : AbstractTextDumper
|
||||
bool m_wrote_header;
|
||||
|
||||
void WriteHeader();
|
||||
void WriteReference(const std::string& reference) const;
|
||||
|
||||
public:
|
||||
StringFileDumper(Zone* zone, std::ostream& stream);
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
namespace utils
|
||||
{
|
||||
#define M_LETTERS_AL_NUM "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
static constexpr const char* LETTERS_AL_NUM = M_LETTERS_AL_NUM;
|
||||
static constexpr const char* LETTERS_AL_NUM_UNDERSCORE = M_LETTERS_AL_NUM "_";
|
||||
|
||||
std::string EscapeStringForQuotationMarks(const std::string_view& str);
|
||||
void EscapeStringForQuotationMarks(std::ostream& stream, const std::string_view& str);
|
||||
std::string UnescapeStringFromQuotationMarks(const std::string_view& str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user