Format class used to support Android XML file format.

since 1.0.0
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 Android XML file format.

print_exported_file(\GP_Project $project, \GP_Locale $locale, \GP_Translation_Set $translation_set, \GP_Translation $entries) : string
since 1.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

stringThe exported Android XML 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 an Android XML file.

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

Parameters

$file_name

string

The name of the uploaded Android XML file.

Returns

\TranslationsbooleanThe extracted originals on success, false on failure.

read_originals_from_file()

read_originals_from_file($file_name) 
Inherited

Parameters

$file_name

read_translations_from_file()

read_translations_from_file($file_name, $project = null
Inherited

Parameters

$file_name

$project

Escapes a string with c style slashes and html entities as required.

escape(string $string) : string
since 1.0.0

Parameters

$string

string

The string to escape.

Returns

stringReturns the escaped string.

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.

Compare two context strings for a uasort callback.

cmp_context(string $a, string $b) : integer
since 1.0.0

Parameters

$a

string

The first string to compare.

$b

string

The second string to compare.

Returns

integerReturns the result of the comparison.

Extracts the xliff information from a string.

extract_xliff_info(string $string) : array | boolean
since 1.0.0

Parameters

$string

string

The string to process.

Returns

arraybooleanAn array containing the extracted information from the xliff tags (there may be multiple) on success, false on failure.

Generates a translation entry object to be added to the results for the "read_originals_from_file()" function.

generate_entry(\obj $string, string $context) : \obj
since 1.0.0

Parameters

$string

\obj

The string entry object to use.

$context

string

The context string to use.

Returns

\objA translation entry object.

Save a line to the exported class variable. Supports prepending of tabs and appending a newline to the string.

line(string $string, integer $prepend_tabs = 0
since 1.0.0

Parameters

$string

string

The string to process.

$prepend_tabs

integer

The number of tab characters to prepend to the output.

Preserve a Unicode sequence (like \u1234) by adding another backslash.

preserve_escaped_unicode(string $string) : string
since 3.0

Parameters

$string

string

The string to process.

Returns

stringReturns the string with double-escaped Unicode sequences.

Output the strings array entries to the exported class variable.

string_arrays(\obj $entries) 
since 1.0.0

Parameters

$entries

\obj

The entries to store.

Unescapes a string with c style slashes.

unescape(string $string) : string
since 1.0.0

Parameters

$string

string

The string to unescape.

Returns

stringReturns the unescaped string.

 Properties

 

$alt_extensions

$alt_extensions 

Default

array()
 

Storage for the export file contents while it is being generated.

$exported : string

Default

''
since 1.0.0
 

File extension of the file format, used to autodetect formats and when creating the output file names.

$extension : string

Default

'xml'
since 1.0.0
inherited_from \GP_Format::extension
 

$extension

$extension 

Default

''
 

$filename_pattern

$filename_pattern 

Default

'%s-%s'
 

Name of file format, used in file format dropdowns.

$name : string

Default

'Android XML (.xml)'
since 1.0.0
inherited_from \GP_Format::name
 

$name

$name 

Default

''