<<

NAME

ProductOpener::Lang - load and return translations

SYNOPSIS

ProductOpener::Lang loads translations from .po files and return translated strings through the lang() and lang_sprintf() functions.

DESCRIPTION

FUNCTIONS

separator_before_colon( $l )

Arguments

language code $l

In some languages like French, colons have a space before them. e.g. "Valeur : 500" in French, "Value: 500" in English

This function returns a non-breaking space character for those languages.

lang( $stringid )

Returns a translation for a specific string id in the language defined in the $lc global variable.

If a translation is not available, the function returns English.

Arguments

string id $stringid

In the .po translation files, we use the msgctxt field for the string id.

f_lang( $stringid, $variables_ref )

Returns a translation for a specific string id with specific arguments in the language defined in the $lc global variable.

The translation is stored using Python's f-string format with named parameters between { }.

e.g. "This is a string with {a_variable} and {another_variable}."

Variables between { } are interpolated with the corresponding entry in the $variables_ref hash reference.

If a translation is not available, the function returns English.

Arguments

string id $stringid

In the .po translation files, we use the msgctxt field for the string id.

variables hash reference $variables_ref

Reference to a hash that contains values for the variables that will be replaced.

f_lang_in_lc ( $target_lc, $stringid, $variables_ref )

Returns a translation for a specific string id with specific arguments in the language $target_lc.

The translation is stored using Python's f-string format with named parameters between { }.

e.g. "This is a string with {a_variable} and {another_variable}."

Variables between { } are interpolated with the corresponding entry in the $variables_ref hash reference.

If a translation is not available, the function returns English.

Arguments

 =head4 target language $target_lc

string id $stringid

In the .po translation files, we use the msgctxt field for the string id.

variables hash reference $variables_ref

Reference to a hash that contains values for the variables that will be replaced.

lang_in_other_lc( $target_lc, $stringid )

Returns a translation for a specific string id in a specific language.

If a translation is not available, the function returns English.

Arguments

target language code $target_lc

string id $stringid

In the .po translation files, we use the msgctxt field for the string id.

<<