[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Translations' (#lazutils)

TPOFile.Translate

Retrieves the translation entry for the specified identifier and returns the translated value.

Declaration

Source position: translations.pas line 141

public function TPOFile.Translate(

  const Identifier: string;

  const OriginalValue: string

):string;

Arguments

Identifier

  

Identifier (msgid) for the translation entry used in the method.

OriginalValue

  

Original untranslated value for the specified Identifier.

Function result

Translated value for the identifier, or the original value if a translation cannot be located or used.

Description

Translate is a method used to retrieve the translation entry for a given identifier, and return the translated value for the TPOFileItem.

Identifier contains the msgid for the translation entry.

OriginalValue contains the untranslated value for the Identifier.

A translation is loaded only when it exists, and does not include 'fuzzy' or 'badformat' in its flag values. This is done to mimic gettext behavior and to avoid crashes related to formatting argument mismatches.

The return value contains the Translation property for the TPOFileItem when found. When not found, the value in the Original property is used. If the translated value is an empty string (''), the untranslated value in OriginalValue is used as the return value for the method.

Translate is called from the implementation routine used in the TranslateUnitResourceStrings routine.

Errors

Raises an exception with the message 'TPOFile.Translate Inconsistency' if a translation is not found (or created) for the Identifier, or the flags for the translation include 'fuzzy' or 'badformat'.


Version 4.0 Generated 2025-05-03 Home