Format class used to support Mac OS X / iOS Translate strings 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 strings 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 strings 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 strings 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 strings 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

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.

Adds escaping to a string.

escape(string $string) : string
since 1.0.0

Parameters

$string

string

The string to add escapes to.

Returns

stringThe escaped string.

Sorts the translation entries based on the context attribute.

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

Parameters

$a

string

First string to compare.

$b

string

Second string to compare.

Returns

integer+1 or -1 based on the order to sort.

Strips any escaping from a string.

unescape(string $string) : string
since 1.0.0

Parameters

$string

string

The string to strip escapes from.

Returns

stringThe unescaped string.

 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

'strings'
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

'Mac OS X / iOS Strings File (.strings)'
since 1.0.0
inherited_from \GP_Format::name
 

$name

$name 

Default

''