localizedKey - multiple declarations

Function localizedKey

Construct localized key name from key and locale.

String localizedKey(String) (
  String key,
  String locale
) pure nothrow @safe
if (isSomeString!String && is(ElementEncodingType!String : char));

Returns

localized key in form key[locale] dropping encoding out if present.

See Also

separateFromLocale

Example

string key = "Name";
assert(localizedKey(key, "") == key);
assert(localizedKey("Name", "ru_RU") == "Name[ru_RU]");
assert(localizedKey("Name", "ru_RU.UTF-8") == "Name[ru_RU]");

Function localizedKey

ditto, but constructs locale name from arguments.

String localizedKey(String) (
  String key,
  String lang,
  String country,
  String modifier = null
) pure @safe
if (isSomeString!String && is(ElementEncodingType!String : char));

Example

assert(localizedKey("Name", "ru", "RU") == "Name[ru_RU]");
assert(localizedKey("Name".dup, "ru".dup, "RU".dup) == "Name[ru_RU]".dup);