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

TPOFile

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Class used to represent a .po file with translation entries for a single target language.

Declaration

Source position: translations.pas line 112

type TPOFile = class

protected

  FItems: TFPList;

  

Member with the list of TPOFileItem instances in POItems.

  FIdentifierLowToItem: TStringToPointerTree;

  

Member with the lowercase identifier to TPOFileItem mapping.

  FOriginalToItem: TStringHashList;

  

Member with the original value to TPOFileItem mapping.

  FCharSet: string;

  

Member with the value for the CharSet property.

  FHeader: TPOFileItem;

  

Member with the value for the Header property.

  FAllEntries: Boolean;

  

Member with the scope for the translations applied from the .po file.

  FTag: Integer;

  

Member with the value for the Tag property.

  FModified: Boolean;

  

Member with the value for the Modified property.

  FHelperList: TStringList;

  

Member with the string list used to convert the .po file in the SaveToStrings method.

  FPoName: string;

  

Member with the value for the POName and PORename properties.

  function Remove();

  

Gets the translation entry at the specified ordinal position in POItems and removes it from the list.

  function GetCount;

  

Gets the value for the Count property.

  procedure SetCharSet();

  

Updates the value in the CharSet property.

  function GetPoItem();

  

Gets the value for the indexed POItems property.

  procedure ReadPOText();

  

Reads the content for the .po file from the specified source.

public

  constructor Create();

  

Constructor for the class instance.

  destructor Destroy; override;

  

Destructor for the class instance.

  function Translate();

  

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

  property CharSet: string; [r]

  

Character set used for the contents of the .po file.

  procedure Report();

  

Generates output with the values in the Header and the translation entries in the .po file.

  procedure CreateHeader;

  

Ensures that a TPOFileItem instance is allocated for the Header property (when not already assigned).

  procedure UpdateStrings();

  

Adds or updates translation entries in POItems using the values specified in InputLines.

  procedure SaveToStrings();

  

Stores values from Header and the sorted POItems to the specified string list.

  procedure SaveToFile();

  

Stores values from Header and the sorted POItems to the specified file name.

  procedure UpdateItem();

  

Adds or updates a translation entry which has the specified Identifier.

  procedure FillItem();

  

Stores argument values to the specified translation entry.

  procedure UpdateTranslation();

  

Updates or removes translation entries in the .po file class based on the content in the specified .po file.

  procedure UntagAll;

  

Resets the value in the Tag property for all of the translation entries in Items.

  procedure RemoveTaggedItems();

  

Removes translation entries in POItems with the specified value in their Tag property.

  procedure RemoveIdentifier();

  

Removes a translation entry in Items with the specified value in its identifier (msgid).

  procedure RemoveOriginal();

  

Removes a translation entry in POItems with has the specified value as its Original untranslated value.

  procedure RemoveIdentifiers();

  

Removes translation entries from Items which have the identifiers (msgids) in the specified string list.

  procedure RemoveOriginals();

  

Removes translation entries from Items which have the original untranslated values in the specified string list.

  property Tag: Integer; [rw]

  

Arbitrary value used to identify the .po file and its associated translation entries.

  property Modified: Boolean; [r]

  

Indicates whether values in the class instance have been modified since they were loaded from a .po file or stream.

  property Items: TFPList; [r]

  

Provides access to the TFPList instance where translation entries are stored.

  property PoName: string; [r]

  

Name for the .po file loaded into the class instance.

  property PoRename: string; [w]

  

Name for the .po file loaded into the class instance.

  property Statistics: TTranslationStatistics; [r]

  

Provides access to statistics for the translation entries in the .po file.

  procedure InvalidateStatistics;

  

Resets the internal flag which indicates that translation statistics has been calculated for the entries in POItems.

  function FindPoItem();

  

Gets the translation entry with the specified identifier value.

  function OriginalToItem();

  

Gets the translation entry which has the specified original (untranslated) value.

  property PoItems []: TPOFileItem; [r]

  

Provides indexed access to the translation entries in the class instance.

  property Count: Integer; [r]

  

Number of translation entries in the POItems for the class instance.

  property Header: TPOFileItem; [r]

  

Contains values for the header section in a .po file.

end;

Inheritance

TPOFile

  

Class used to represent a .po file with translation entries for a single target language.

|

TObject

Description

TPOFile is a class which provides access to a file with translation entries used to localize a source file to the language or locale defined in a .po (Portable Object) file. .po files are part of the GNU gettext tool set used to produce and update translation files. Information about the .po file format can be found at:

The Format of PO Files

TPOFile provides properties and methods used to load and save translation entries using a file, stream, or resource. The Header property contains the header information for the .po file, and may contain information about: the MIME version and content transfer encoding, target language, plural forms, and generation tools. Use the POItems property to access the translation entries defined in the .po file.

TPOFile also provides Statistics about the translations applied to a source file when the Translate method is called.

See also

TPOFileItem

  

Represents a single key/value pair in a .po file which maps a string to its translated value.


Version 4.0 Generated 2025-05-03 Home