mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Add clientside translations.
This commit is contained in:
parent
b28af0ed07
commit
b24e6433df
21 changed files with 629 additions and 46 deletions
|
@ -203,6 +203,56 @@ inline bool str_starts_with(const std::basic_string<T> &str,
|
|||
case_insensitive);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether \p str ends with the string suffix. If \p case_insensitive
|
||||
* is true then the check is case insensitve (default is false; i.e. case is
|
||||
* significant).
|
||||
*
|
||||
* @param str
|
||||
* @param suffix
|
||||
* @param case_insensitive
|
||||
* @return true if the str begins with suffix
|
||||
*/
|
||||
template <typename T>
|
||||
inline bool str_ends_with(const std::basic_string<T> &str,
|
||||
const std::basic_string<T> &suffix,
|
||||
bool case_insensitive = false)
|
||||
{
|
||||
if (str.size() < suffix.size())
|
||||
return false;
|
||||
|
||||
size_t start = str.size() - suffix.size();
|
||||
if (!case_insensitive)
|
||||
return str.compare(start, suffix.size(), suffix) == 0;
|
||||
|
||||
for (size_t i = 0; i < suffix.size(); ++i)
|
||||
if (tolower(str[start + i]) != tolower(suffix[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether \p str ends with the string suffix. If \p case_insensitive
|
||||
* is true then the check is case insensitve (default is false; i.e. case is
|
||||
* significant).
|
||||
*
|
||||
* @param str
|
||||
* @param suffix
|
||||
* @param case_insensitive
|
||||
* @return true if the str begins with suffix
|
||||
*/
|
||||
template <typename T>
|
||||
inline bool str_ends_with(const std::basic_string<T> &str,
|
||||
const T *suffix,
|
||||
bool case_insensitive = false)
|
||||
{
|
||||
return str_ends_with(str, std::basic_string<T>(suffix),
|
||||
case_insensitive);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Splits a string into its component parts separated by the character
|
||||
* \p delimiter.
|
||||
|
@ -598,6 +648,12 @@ std::vector<std::basic_string<T> > split(const std::basic_string<T> &s, T delim)
|
|||
return tokens;
|
||||
}
|
||||
|
||||
std::wstring translate_string(const std::wstring &s);
|
||||
|
||||
inline std::wstring unescape_translate(const std::wstring &s) {
|
||||
return unescape_enriched(translate_string(s));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that all characters in \p to_check are a decimal digits.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue