NAME
Text::PO::Element - PO Element
SYNOPSIS
use Text::PO::Element;
my $po = Text::PO::Element->new;
$po->debug(2);
$po->dump;
VERSION
v0.4.0
DESCRIPTION
This is the class for PO elements.
A typical PO element might look like this:
white-space
# translator-comments
#. extracted-comments
#: reference...
#, flag...
#| msgid previous-untranslated-string
msgid untranslated-string
msgstr translated-string
See more information fromt he GNU documentation
CONSTRUCTOR
new
Create a new Text::PO::Element object acting as an accessor.
You can pass it an hash or hash reference of the following keys. For more information on those, see their corresponding method:
msgid
msgstr
msgid_plural
auto_comment
comment
context
encoding
file
flags
is_meta
line
fuzzy
plural
po
ATTRIBUTES
A Text::PO::Element
object has the following fields :
msgid
The localisation id
msgstr
The localised string
msgid_plural
The optional localised string in plural
context
The optional context.
The context serves to disambiguate messages with the same untranslated-string. It is possible to have several entries with the same untranslated-string in a PO file, provided that they each have a different context. Note that an empty context string and an absent msgctxt line do not mean the same thing.
https://www.gnu.org/software/gettext/manual/html_node/Entries-with-Context.html
fuzzy
The fuzzy flag set when the entry has been created but not yet translated
See also the GNU PO documentation
comment
# translator-comments
The optional comment that can be added to provide some explanations to the translator
auto_comment
#. extracted-comments
The optional comment added automatically
flags
#, flag...
An optional set of flags, stored as an array reference
For example:
#: src/msgcmp.c:338 src/po-lex.c:699 #, c-format msgid "found %d fatal error" msgid_plural "found %d fatal errors" msgstr[0] "s'ha trobat %d error fatal" msgstr[1] "s'han trobat %d errors fatals"
Here the flag would be
c-format
See also the GNU PO documentation and here, and the list of flags
Known flags are:
c-format
orno-c-format
The
c-format
flag indicates that the untranslated string and the translation are supposed to be C format strings. Theno-c-format
flag indicates that they are not C format strings, even though the untranslated string happens to look like a C format string (with ‘%’ directives).objc-format
orno-objc-format
Likewise for Objective C
c++-format
orno-c++-format
Likewise for C++
python-format
orno-python-format
Likewise for Python
python-brace-format
orno-python-brace-format
Likewise for Python brace
java-format
orno-java-format
Likewise for Java MessageFormat format strings
java-printf-format
orno-java-printf-format
Likewise for Java printf format strings
csharp-format
orno-csharp-format
Likewise for C# Format Strings
javascript-format
orno-javascript-format
Likewise for JavaScript Format Strings
scheme-format
orno-scheme-format
Likewise for Scheme Format Strings
lisp-format
orno-lisp-format
Likewise for Lisp Format Strings
lisp-format
orno-lisp-format
Likewise for Lisp Format Strings
elisp-format
orno-elisp-format
Likewise for Emacs Lisp Format Strings
librep-format
orno-librep-format
Likewise for librep Format Strings
rust-format
orno-rust-format
Likewise for Rust Format Strings
go-format
orno-go-format
Likewise for Go Format Strings
sh-format
orno-sh-format
Likewise for Shell Format Strings
sh-printf-format
orno-sh-printf-format
Likewise for Shell Format Strings
awk-format
no-awk-format
Likewise for awk Format Strings
lua-format
orno-lua-format
Likewise for Lua Format Strings
object-pascal-format
orno-object-pascal-format
Likewise for Object Pascal Format Strings
modula2-format
orno-modula2-format
Likewise for Modula-2 Format Strings
d-format
orno-d-format
Likewise for D Format Strings
smalltalk-format
orno-smalltalk-format
Likewise for Smalltalk Format Strings
qt-format
orno-qt-format
Likewise for Qt Format Strings
qt-plural-format
orno-qt-plural-format
Likewise for Qt plural forms Format Strings
kde-format
orno-kde-format
Likewise for KDE Format Strings
boost-format
orno-boost-format
Likewise for Boost Format Strings
tcl-format
orno-tcl-format
Likewise for Tcl Format Strings
perl-format
orno-perl-format
Likewise for Perl Format Strings
perl-brace-format
orno-perl-brace-format
Likewise for Perl brace Format Strings
php-format
orno-php-format
Likewise for PHP Format Strings
gcc-internal-format
orno-gcc-internal-format
Likewise for the GCC internal Format Strings
gfc-internal-format
orno-gfc-internal-format
Likewise for the GNU Fortran Compiler internal Format Strings in sources up to GCC 14.x. These flags are deprecated.
ycp-format
orno-ycp-format
Likewise for YCP Format Strings
Other flags, assigned by the programmer, are:
no-wrap
This flag influences the presentation of the entry in the PO file. By default, when a PO file is output by a GNU gettext program and the option ‘--no-wrap’ is not specified, message lines that exceed the output page width are split into several lines. This flag inhibits this line breaking for the entry. This is useful for entries whose lines are close to 80 columns wide.
plural
Whether this has a plural form
encoding
The character encoding
file
The file in which this l10n string was found. This is set when automatic parsing was executed
For example:
#: lib/error.c:116 msgid "Unknown system error" msgstr "Error desconegut del sistema"
This would specify a file
lib/error.c
and a line number116
line
The line at which this l10n was found. This is set when automatic parsing was executed
po
The parent
Text::PO
objectis_meta
An optional boolean value provided if this element represents a meta information
METHODS
add_auto_comment
Add an auto comment
add_comment
Add a comment
add_msgid
Add a msgid
add_msgid_plural
Add a plural version of a msgid
add_msgstr
Add a msgstr
add_reference
Add a reference, which is a file and line number
auto_comment
Set or return the auto_comment field
comment
Set or return the comment field
context
Set or return the context field
delete
Remove the element from the list of elements in Text::PO
This only works if the element was added via Text::PO, or else you need to have set yourself the Text::PO object with the "po" method.
dump
Return the element as a string formatted for a po file.
encoding
Set or get the encoding for this element. This defaults to an empty string
file
Set or get the file path where this PO element was initially be found.
flags
Set or return the flags as array reference
fuzzy
Set or gets whether this element has the fuzzy
flag. Default to false.
id
Return the value of msgid as a string
is_meta
Set or gets the flag that this element represents the meta information for this PO (a.k.a portable object) file.
Meta information for a po file is stored in a unique msgid whose value is null.
line
Set or get the line number at which this PO element was initially be found.
merge( Text::PO::Element )
Given a Text::PO::Element
object, it merge its content with our element object.
The merge will not overwrite existing fields.
It returns the current object
msgid
Sets or gets the msgid
for this element.
In list context, this return the element as an array. Thus. if this element has multiple lines, it will return an array of lines. In scalar context, it returns this element as a string, or if it is a multi line element, it will return an array reference.
msgid_plural
Sets or gets the msgid
version for plural. This is typically a 2-elements array. The first one singular and the second one plural.
msgid_as_string
This returns the msgid escaped and with surrounding quotes, suitable for "dump"
msgid_as_text
This returns a simple text representation of the msgid
. It differs from msgid_as_string in that this is simply the string representation of the msgid
, but would not be suitable for a PO file.
msgid_plural_as_string
Returns the msgid
property as a string when it has plural implemented.
msgstr
Set or return the msgstr as a value without surrounding quote and without escaping.
msgstr_as_string
This returns the msgstr escaped and with surrounding quotes, suitable for "dump"
msgstr_as_text
This returns a simple text representation of the msgstr
. It differs from msgstr_as_string in that this is simply the string representation of the msgstr
, but would not be suitable for a PO file.
normalise
"normalise" will return a string properly formatted with double quotes, multi lines if necessary, suitable for "dump"
plural
Boolean. Sets or gets whether this element is an element with plural version of its msgid
po
Sets or gets the Text::PO object associated with this element. Best that you know what you are doing if you change this.
reference
#: lib/error.c:116
Given an array reference or a string separated by ':', it sets the file and line number for this element object.
wrap
Given a text, it returns an array reference of lines wrapped
wrap_line
Given a string, it returns an array reference of lines. This is called by "wrap"
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html
COPYRIGHT & LICENSE
Copyright (c) 2020-2023 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.