MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / getString

Method getString

src/Engine/Language.cpp:490–514  ·  view source on GitHub ↗

* Returns the localized text with the specified ID, in the proper form for @a n. * The substitution of @a n has already happened in the returned LocalizedText. * If it's not found, just returns the ID. * @param id ID of the string. * @param n Number to use to decide the proper form. * @return String with the requested ID. */

Source from the content-addressed store, hash-verified

488 * @return String with the requested ID.
489 */
490LocalizedText Language::getString(const std::string &id, unsigned n) const
491{
492 assert(!id.empty());
493 std::map<std::string, LocalizedText>::const_iterator s = _strings.end();
494 if (0 == n)
495 {
496 // Try specialized form.
497 s = _strings.find(id + "_zero");
498 }
499 if (s == _strings.end())
500 {
501 // Try proper form by language
502 s = _strings.find(id + _handler->getSuffix(n));
503 }
504 if (s == _strings.end())
505 {
506 Log(LOG_WARNING) << id << " not found in " << Options::language;
507 return LocalizedText(utf8ToWstr(id));
508 }
509 std::wostringstream ss;
510 ss << n;
511 std::wstring marker(L"{N}"), val(ss.str()), txt(s->second);
512 replace(txt, marker, val);
513 return txt;
514}
515
516/**
517 * Returns the localized text with the specified ID, in the proper form for the gender.

Callers 15

State.cppFile · 0.45
trMethod · 0.45
getDayStringMethod · 0.45
getNameMethod · 0.45
getNameMethod · 0.45
getCraftStringMethod · 0.45
getNameMethod · 0.45
getNameMethod · 0.45
getNameMethod · 0.45
getSaveInfoMethod · 0.45
getNameMethod · 0.45
getNameMethod · 0.45

Calls 3

getSuffixMethod · 0.80
LocalizedTextClass · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected