std::wstring key = textdomain + L"|" + s;
try {
return m_translations.at(key);
- } catch (std::out_of_range) {
- warningstream << "Translations: can't find translation for string \""
+ } catch (const std::out_of_range &) {
+ verbosestream << "Translations: can't find translation for string \""
<< wide_to_utf8(s) << "\" in textdomain \""
<< wide_to_utf8(textdomain) << "\"" << std::endl;
// Silence that warning in the future
while (is.good()) {
std::getline(is, line);
+ // Trim last character if file was using a \r\n line ending
+ if (line.length () > 0 && line[line.length() - 1] == '\r')
+ line.resize(line.length() - 1);
+
if (str_starts_with(line, "# textdomain:")) {
textdomain = utf8_to_wide(trim(str_split(line, ':')[1]));
}
<< wide_to_utf8(oword1) << "\"" << std::endl;
}
- m_translations[textdomain + L"|" + oword1] = oword2;
+ std::wstring translation_index = textdomain + L"|";
+ translation_index.append(oword1);
+ m_translations[translation_index] = oword2;
}
-}
\ No newline at end of file
+}