Extra strings: Add no-translate tag
This commit is contained in:
@@ -231,15 +231,6 @@ void FileStringReader::HandlePragma(char *str)
|
|||||||
} else {
|
} else {
|
||||||
error("Invalid override mode %s", str + 9);
|
error("Invalid override mode %s", str + 9);
|
||||||
}
|
}
|
||||||
} else if (!memcmp(str, "override ", 9)) {
|
|
||||||
if (this->translation) error("Overrides are only allowed in the base translation.");
|
|
||||||
if (!memcmp(str + 9, "on", 2)) {
|
|
||||||
this->data.override_mode = true;
|
|
||||||
} else if (!memcmp(str + 9, "off", 3)) {
|
|
||||||
this->data.override_mode = false;
|
|
||||||
} else {
|
|
||||||
error("Invalid override mode %s", str + 9);
|
|
||||||
}
|
|
||||||
} else if (!memcmp(str, "after ", 6)) {
|
} else if (!memcmp(str, "after ", 6)) {
|
||||||
if (this->translation) error("Insert after is only allowed in the base translation.");
|
if (this->translation) error("Insert after is only allowed in the base translation.");
|
||||||
LangString *ent = this->data.Find(str + 6);
|
LangString *ent = this->data.Find(str + 6);
|
||||||
@@ -269,6 +260,15 @@ void FileStringReader::HandlePragma(char *str)
|
|||||||
} else {
|
} else {
|
||||||
error("Can't find string to use as default translation: '%s'", str + 20);
|
error("Can't find string to use as default translation: '%s'", str + 20);
|
||||||
}
|
}
|
||||||
|
} else if (!memcmp(str, "no-translate ", 13)) {
|
||||||
|
if (this->translation) error("No-translate sections are only allowed in the base translation.");
|
||||||
|
if (!memcmp(str + 13, "on", 2)) {
|
||||||
|
this->data.no_translate_mode = true;
|
||||||
|
} else if (!memcmp(str + 13, "off", 3)) {
|
||||||
|
this->data.no_translate_mode = false;
|
||||||
|
} else {
|
||||||
|
error("Invalid no-translate mode %s", str + 13);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
StringReader::HandlePragma(str);
|
StringReader::HandlePragma(str);
|
||||||
}
|
}
|
||||||
|
@@ -37,6 +37,7 @@ struct LangString {
|
|||||||
Case *translated_case; ///< Cases of the translation.
|
Case *translated_case; ///< Cases of the translation.
|
||||||
std::unique_ptr<LangString> chain_before;
|
std::unique_ptr<LangString> chain_before;
|
||||||
std::unique_ptr<LangString> chain_after;
|
std::unique_ptr<LangString> chain_after;
|
||||||
|
bool no_translate_mode = false;
|
||||||
LangString *default_translation = nullptr;
|
LangString *default_translation = nullptr;
|
||||||
|
|
||||||
LangString(const char *name, const char *english, int index, int line);
|
LangString(const char *name, const char *english, int index, int line);
|
||||||
@@ -57,6 +58,7 @@ struct StringData {
|
|||||||
LangString *insert_before = nullptr;
|
LangString *insert_before = nullptr;
|
||||||
LangString *insert_after = nullptr;
|
LangString *insert_after = nullptr;
|
||||||
bool override_mode = false;
|
bool override_mode = false;
|
||||||
|
bool no_translate_mode = false;
|
||||||
LangString *default_translation = nullptr;
|
LangString *default_translation = nullptr;
|
||||||
|
|
||||||
StringData(size_t tabs);
|
StringData(size_t tabs);
|
||||||
|
@@ -770,6 +770,7 @@ void StringReader::HandleString(char *str)
|
|||||||
|
|
||||||
/* Allocate a new LangString */
|
/* Allocate a new LangString */
|
||||||
std::unique_ptr<LangString> ls(new LangString(str, s, this->data.next_string_id, _cur_line));
|
std::unique_ptr<LangString> ls(new LangString(str, s, this->data.next_string_id, _cur_line));
|
||||||
|
if (this->data.no_translate_mode) ls->no_translate_mode = true;
|
||||||
this->data.next_string_id = -1;
|
this->data.next_string_id = -1;
|
||||||
this->data.Add(str, ls.get());
|
this->data.Add(str, ls.get());
|
||||||
|
|
||||||
@@ -796,6 +797,11 @@ void StringReader::HandleString(char *str)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ent->no_translate_mode && _translation) {
|
||||||
|
strgen_error("String name '%s' is marked as no-translate", str);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ent->translated && casep == nullptr) {
|
if (ent->translated && casep == nullptr) {
|
||||||
if (this->data.override_mode) {
|
if (this->data.override_mode) {
|
||||||
free(ent->translated);
|
free(ent->translated);
|
||||||
@@ -1024,7 +1030,7 @@ void LanguageWriter::WriteLang(const StringData &data)
|
|||||||
|
|
||||||
for (uint j = 0; j != in_use[tab]; j++) {
|
for (uint j = 0; j != in_use[tab]; j++) {
|
||||||
const LangString *ls = data.strings[(tab * TAB_SIZE) + j];
|
const LangString *ls = data.strings[(tab * TAB_SIZE) + j];
|
||||||
if (ls != nullptr && ls->translated == nullptr && ls->default_translation == nullptr) {
|
if (ls != nullptr && ls->translated == nullptr && ls->default_translation == nullptr && !ls->no_translate_mode) {
|
||||||
_lang.missing++;
|
_lang.missing++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user