Make some enhancements to the POT generation

This commit is contained in:
Michael Alexsander
2021-08-01 02:53:36 -03:00
parent 29a3300c6a
commit ee4b0108e0
6 changed files with 58 additions and 19 deletions

View File

@ -108,7 +108,6 @@ void POTGenerator::_write_to_pot(const String &p_file) {
const String header =
"# LANGUAGE translation for " + project_name + " for the following files:\n" + extracted_files +
"#\n"
"#\n"
"# FIRST AUTHOR < EMAIL @ADDRESS>, YEAR.\n"
"#\n"
"#, fuzzy\n"
@ -116,8 +115,9 @@ void POTGenerator::_write_to_pot(const String &p_file) {
"msgstr \"\"\n"
"\"Project-Id-Version: " +
project_name + "\\n\"\n"
"\"MIME-Version: 1.0\\n\"\n"
"\"Content-Type: text/plain; charset=UTF-8\\n\"\n"
"\"Content-Transfer-Encoding: 8-bit\\n\"\n\n";
"\"Content-Transfer-Encoding: 8-bit\\n\"\n";
file->store_string(header);
@ -129,6 +129,9 @@ void POTGenerator::_write_to_pot(const String &p_file) {
String plural = v_msgid_data[i].plural;
const Set<String> &locations = v_msgid_data[i].locations;
// Put the blank line at the start, to avoid a double at the end when closing the file.
file->store_line("");
// Write file locations.
for (Set<String>::Element *E = locations.front(); E; E = E->next()) {
file->store_line("#: " + E->get().trim_prefix("res://"));
@ -142,13 +145,13 @@ void POTGenerator::_write_to_pot(const String &p_file) {
// Write msgid.
_write_msgid(file, msgid, false);
// Write msgid_plural
// Write msgid_plural.
if (!plural.is_empty()) {
_write_msgid(file, plural, true);
file->store_line("msgstr[0] \"\"");
file->store_line("msgstr[1] \"\"\n");
file->store_line("msgstr[1] \"\"");
} else {
file->store_line("msgstr \"\"\n");
file->store_line("msgstr \"\"");
}
}
}