GlotPress Format base class. It is supposed to be inherited.

package GlotPress
inherited_from \GP_Format

 Methods

Gets the list of supported file extensions.

get_file_extensions() : array
Inherited
since 2.0.0

Returns

arraySupported file extensions.

Generates a string the contains the $entries to export in the Properties file format.

print_exported_file(\GP_Project $project, \GP_Locale $locale, \GP_Translation_Set $translation_set, \GP_Translation $entries) : string
since 2.0.0
inherited_from \GP_Format::print_exported_file()

Parameters

$project

\GP_Project

The project the strings are being exported for, not used in this format but part of the scaffold of the parent object.

$locale

\GP_Locale

The locale object the strings are being exported for. not used in this format but part of the scaffold of the parent object.

$translation_set

\GP_Translation_Set

The locale object the strings are being exported for. not used in this format but part of the scaffold of the parent object.

$entries

\GP_Translation

The entries to export.

Returns

string

print_exported_file()

print_exported_file($project, $locale, $translation_set, $entries) 
Inherited

Parameters

$project

$locale

$translation_set

$entries

Reads a set of original strings from a properties file.

read_originals_from_file(string $file_name) : \Translations | boolean
since 2.0.0
inherited_from \GP_Format::read_originals_from_file()

Parameters

$file_name

string

The filename of the uploaded properties file.

Returns

\Translationsboolean

read_originals_from_file()

read_originals_from_file($file_name) 
Inherited

Parameters

$file_name

Reads a set of translations from a properties file.

read_translations_from_file(string $file_name, \GP_Project $project = null) : \Translations | boolean
since 2.0.0
inherited_from \GP_Format::read_translations_from_file()

Parameters

$file_name

string

The filename of the uploaded properties file.

$project

\GP_Project

The project object to read the translations in to.

Returns

\Translationsboolean

read_translations_from_file()

read_translations_from_file($file_name, $project = null
Inherited

Parameters

$file_name

$project

Create a string that represents the value for the "Language:" header for an export file.

get_language_code(\GP_Locale $locale) : string | false
Inherited
since 2.1.0

Parameters

$locale

\GP_Locale

The locale object.

Returns

stringfalseReturns false if the locale object does not have any iso_639 language code, otherwise returns the shortest possible language code string.

Encodes a PHP string in ascii format to a unicode escaped string (multi-byte characters are encoded in the \uXXXX format).

ascii_uni_encode(string $string) : string
since 2.0.0

Parameters

$string

string

The string to encode.

Returns

string

Escape a string to be used as a value in the properties file.

escape(string $string) : string
since 2.0.0

Parameters

$string

string

The string to escape.

Returns

string

Escape a string to be used as a key name in the properties file.

escape_key(string $string) : string
since 2.0.0

Parameters

$string

string

The string to escape.

Returns

string

Part of utf8_uni_encode(), this returns the character value of a UTF-8 encoded string.

ordutf8(string $string, integer $offset) : integer | boolean
since 2.0.0

Parameters

$string

string

The UTF-8 string to process.

$offset

integer

The offset of the string to return the character value of.

Returns

integerboolean

The callback to sort the entries by, used above in print_exported_file().

sort_entries(\Translations $a, \Translations $b) : integer
since 2.0.0

Parameters

$a

\Translations

The first translation to compare.

$b

\Translations

The second translation to compare.

Returns

integer

Splits a properties file line on the = or : character.

split_properties_line(string $line, string $key, string $value) : boolean

Skips escaped values (\= or \:) in the key and matches the first unescaped instance.

since 2.0.0

Parameters

$line

string

The line to split.

$key

string

The key part of the properties file string if found.

$value

string

The value part of the properties file string if found.

Returns

booleanReturns true if the line was split successfully, false otherwise.

Unescape a string to be used as a value in the properties file.

unescape(string $string) : string
since 2.0.0

Parameters

$string

string

The string to unescape.

Returns

string

Decodes a unicode escaped string to a PHP string.

uni_decode(string $string) : string
since 2.0.0

Parameters

$string

string

The string to decode.

Returns

string

Part of uni_decode(), this is the call back function that does the heavy lifting of converting a \uXXXX value to a UTF-8 encoded character sequence.

uni_decode_callback(array $matches) : string
since 2.0.0

Parameters

$matches

array

The array of matches from preg_replace_callback().

Returns

string

Encodes a PHP string in UTF8 format to a unicode escaped string (multi-byte characters are encoded in the \uXXXX format).

utf8_uni_encode($string) : string
since 2.0.0

Parameters

$string

string The string to encode.

Returns

string

 Properties

 

$alt_extensions

$alt_extensions 

Default

array()
 

$exported

$exported 

Default

''
 

$extension

$extension 

Default

'properties'
inherited_from \GP_Format::extension
 

$extension

$extension 

Default

''
 

$filename_pattern

$filename_pattern 

Default

'%s_%s'
inherited_from \GP_Format::filename_pattern
 

$filename_pattern

$filename_pattern 

Default

'%s-%s'
 

$name

$name 

Default

'Java Properties File (.properties)'
inherited_from \GP_Format::name
 

$name

$name 

Default

''