vibe.d beta banner
get vibe.d
0.10.0

Asynchronous I/O that doesn’t get in your way, written in D

Function trWeb

Translates text based on the language of the current web request.

string trWeb (
  string text,
  string context = null
) @safe;

string trWeb (
  string text,
  string plural_text,
  int count,
  string context = null
) @safe;

The first overload performs a direct translation of the given translation key/text. The second overload can select from a set of plural forms based on the given integer value (msgid_plural).

Parameters

NameDescription
text The translation key
context Optional context/namespace identifier (msgctxt)
plural_text Plural form of the translation key
count The quantity used to select the proper plural form of a translation

See also

translationContext

Example

struct TRC {
	import std.typetuple;
	alias languages = TypeTuple!("en_US", "de_DE", "fr_FR");
	//mixin translationModule!"test";
}

@translationContext!TRC
class WebService {
	void index(HTTPServerResponse res)
	{
		res.writeBody(trWeb("This text will be translated!"));
	}
}
Authors

Sönke Ludwig

Copyright

© 2013-2016 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.