Skip to main content

pgettext

Translates a message within a specific context by prepending the context and a separator before calling the standard translation function, returning the original message if no translation is found.

def pgettext(
context: string,
message: string
) - > string

Translates a message within a specific context to resolve ambiguities between identical strings used in different parts of an application.

Parameters

NameTypeDescription
contextstringThe context string used to disambiguate the message, such as 'verb' vs 'noun'.
messagestringThe actual text string to be translated.

Returns

TypeDescription
stringThe translated string if a translation exists for the given context; otherwise, the original message string.