Format class used to support JSON file format.
since | 2.3.0 |
---|---|
package | GlotPress |
inherited_from | \GP_Format |
get_file_extensions() : array
since | 2.0.0 |
---|
array
Supported file extensions.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::print_exported_file() |
\GP_Project
The project the strings are being exported for, not used in this format but part of the scaffold of the parent object.
\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.
\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.
\GP_Translation
The entries to export.
string
The exported JSON string.print_exported_file($project, $locale, $translation_set, $entries)
read_originals_from_file(string $file_name) : \Translations | boolean
since | 2.3.0 |
---|---|
inherited_from | \GP_Format::read_originals_from_file() |
string
The name of the uploaded JSON file.
\Translations
boolean
The extracted originals on success, false on failure.read_originals_from_file($file_name)
read_translations_from_file(string $file_name, \GP_Project $project = null
) : \Translations | boolean
since | 2.3.0 |
---|---|
inherited_from | \GP_Format::read_translations_from_file() |
string
The name of the uploaded properties file.
\GP_Project
Unused. The project object to read the translations into.
\Translations
boolean
The extracted translations on success, false on failure.read_translations_from_file($file_name, $project = null
)
decode_json_file(string $file_name) : array | false
since | 2.3.0 |
---|
string
The name of the JSON file to parse.
array
false
The encoded value or false on failure.get_language_code(\GP_Locale $locale) : string | false
since | 2.1.0 |
---|
\GP_Locale
The locale object.
string
false
Returns false if the locale object does not have any iso_639 language code, otherwise returns the shortest possible language code string.$alt_extensions
array()
$extension : string
'json'
since | 2.3.0 |
---|---|
inherited_from | \GP_Format::extension |
$extension
''
$filename_pattern
'%s-%s'
$name : string
'JSON (.json)'
since | 2.3.0 |
---|---|
inherited_from | \GP_Format::name |
$name
''