pass n by value

This commit is contained in:
orignal 2025-03-16 15:17:08 -04:00
parent d93a80cd2b
commit c0b5f2d2ef
2 changed files with 5 additions and 5 deletions

View file

@ -35,7 +35,7 @@ namespace i18n
return i2p::client::context.GetLanguage ()->GetString (arg); return i2p::client::context.GetLanguage ()->GetString (arg);
} }
std::string translate (const std::string& arg, const std::string& arg2, const int& n) std::string translate (const std::string& arg, const std::string& arg2, const int n)
{ {
return i2p::client::context.GetLanguage ()->GetPlural (arg, arg2, n); return i2p::client::context.GetLanguage ()->GetPlural (arg, arg2, n);
} }

View file

@ -49,7 +49,7 @@ namespace i18n
} }
} }
std::string GetPlural (const std::string& arg, const std::string& arg2, const int& n) const std::string GetPlural (const std::string& arg, const std::string& arg2, int n) const
{ {
const auto it = m_Plurals.find(arg2); const auto it = m_Plurals.find(arg2);
if (it == m_Plurals.end()) // not found, fallback to english if (it == m_Plurals.end()) // not found, fallback to english
@ -72,7 +72,7 @@ namespace i18n
void SetLanguage(const std::string &lang); void SetLanguage(const std::string &lang);
std::string_view translate (std::string_view arg); std::string_view translate (std::string_view arg);
std::string translate (const std::string& arg, const std::string& arg2, const int& n); std::string translate (const std::string& arg, const std::string& arg2, int n);
} // i18n } // i18n
} // i2p } // i2p
@ -110,7 +110,7 @@ std::string tr (TValue&& arg, TArgs&&... args)
* @param n Integer, used for selection of form * @param n Integer, used for selection of form
*/ */
template<typename TValue, typename TValue2> template<typename TValue, typename TValue2>
std::string ntr (TValue&& arg, TValue2&& arg2, int& n) std::string ntr (TValue&& arg, TValue2&& arg2, int n)
{ {
return i2p::i18n::translate(std::forward<TValue>(arg), std::forward<TValue2>(arg2), std::forward<int>(n)); return i2p::i18n::translate(std::forward<TValue>(arg), std::forward<TValue2>(arg2), std::forward<int>(n));
} }
@ -123,7 +123,7 @@ std::string ntr (TValue&& arg, TValue2&& arg2, int& n)
* @param args Array of arguments for string formatting * @param args Array of arguments for string formatting
*/ */
template<typename TValue, typename TValue2, typename... TArgs> template<typename TValue, typename TValue2, typename... TArgs>
std::string ntr (TValue&& arg, TValue2&& arg2, int& n, TArgs&&... args) std::string ntr (TValue&& arg, TValue2&& arg2, int n, TArgs&&... args)
{ {
std::string tr_str = i2p::i18n::translate(std::forward<TValue>(arg), std::forward<TValue2>(arg2), std::forward<int>(n)); std::string tr_str = i2p::i18n::translate(std::forward<TValue>(arg), std::forward<TValue2>(arg2), std::forward<int>(n));