Format class used to support PHP file format.

since 4.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 PHP file format.

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

read_originals_from_file(string $file_name) : false
since 4.0.0
inherited_from \GP_Format::read_originals_from_file()

Parameters

$file_name

string

The name of the uploaded PHP file.

Returns

falseAlways returns false, as this is not currently implemented.

read_originals_from_file()

read_originals_from_file($file_name) 
Inherited

Parameters

$file_name

Reads a set of translations from a PHP file.

read_translations_from_file(string $file_name, \GP_Project $project = null) : false
since 4.0.0
inherited_from \GP_Format::read_translations_from_file()

Parameters

$file_name

string

The name of the uploaded properties file.

$project

\GP_Project

Unused. The project object to read the translations into.

Returns

falseAlways returns false, as this is not currently implemented.

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.

Determines if the given array is a list.

array_is_list(\array<mixed> $arr) : boolean

An array is considered a list if its keys consist of consecutive numbers from 0 to count($array)-1.

Polyfill for array_is_list() in PHP 8.1.

see
since 4.0.0
codeCoverageIgnore

Parameters

$arr

\array<mixed>

The array being evaluated.

Returns

booleanTrue if array is a list, false otherwise.

Outputs or returns a parsable string representation of a variable.

var_export(mixed $value) : string

Like \var_export() but "minified", using short array syntax and no newlines.

since 4.0.0

Parameters

$value

mixed

The variable you want to export.

Returns

stringThe variable representation.

 Properties

 

$alt_extensions

$alt_extensions 

Default

array()
 

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

$extension : string

Default

'mo.php'
since 4.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

'PHP (.mo.php)'
since 4.0.0
inherited_from \GP_Format::name
 

$name

$name 

Default

''