Format class used to support Jed 1.x compatible JSON file format.

since 2.3.0
package GlotPress
inherited_from \GP_Format_JSON

 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 Jed 1.x compatible JSON file format.

print_exported_file(\GP_Project $project, \GP_Locale $locale, \GP_Translation_Set $translation_set, \GP_Translation $entries) : string
since 2.3.0
inherited_from \GP_Format_JSON::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 Jed 1.x compatible JSON 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 JSON file.

read_originals_from_file(string $file_name) : \Translations | boolean
since 2.3.0
inherited_from \GP_Format_JSON::read_originals_from_file()

Parameters

$file_name

string

The name of the uploaded JSON 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

Decodes a JSON string and checks for needed array keys.

decode_json_file(string $file_name) : array | false
since 2.3.0
inherited_from \GP_Format_JSON::decode_json_file()

Parameters

$file_name

string

The name of the JSON file to parse.

Returns

arrayfalseThe encoded value or false on failure.

Loads a given JSON file and decodes its content.

decode_json_file(string $file_name) : array | false
Inherited
since 2.3.0

Parameters

$file_name

string

The name of the JSON file to parse.

Returns

arrayfalseThe encoded value or false on failure.

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.

 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

'jed.json'
since 2.3.0
inherited_from \GP_Format_JSON::extension
 

$extension

$extension 

Default

''
 

$filename_pattern

$filename_pattern 

Default

'%s-%s'
 

Name of file format, used in file format dropdowns.

$name : string

Default

'Jed 1.x (.json)'
since 2.3.0
inherited_from \GP_Format_JSON::name
 

$name

$name 

Default

''