]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/translation.cpp
[CSM] Expose more env functions
[dragonfireclient.git] / src / translation.cpp
index 31efca41eaa457a01701800120153d57085b023e..d17467ce75846112ef82038dda155c9b9ef2790c 100644 (file)
@@ -40,8 +40,8 @@ const std::wstring &Translations::getTranslation(
        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
@@ -58,6 +58,10 @@ void Translations::loadTranslation(const std::string &data)
 
        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]));
                }
@@ -145,6 +149,8 @@ void Translations::loadTranslation(const std::string &data)
                                    << 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
+}