![]() |
GravityView
2.17
The best, easiest way to display Gravity Forms entries on your website.
|
Allows downloading and installing translations from TranslationsPress. More...
Public Member Functions | |
convert_po_to_json ( $po_file, $json_file) | |
Converts the PO file to JSON file by extracting only JavaScript translations. More... | |
download_package ( $slug, $locale='') | |
Downloads and installs the translations package for the specified plugin. More... | |
get_available_languages () | |
Returns an array of locales the site has installed. More... | |
get_exception ( $message, $method,... $args) | |
Formats and returns an exception message. More... | |
get_installed_translations ( $return_files=false) | |
Returns an array of locales or .mo translation files found in the translations folder. More... | |
get_installed_translations_data () | |
Returns header data from the installed translations for the current plugin. More... | |
get_plugin_translations () | |
Gets the TranslationsPress data for the current plugin. More... | |
get_remote_translations_data () | |
Gets the translation data from the TranslationsPress API. More... | |
get_slug_from_locale ( $locale) | |
Returns T15S slug for the language based on the WP locale. More... | |
install ( $locale='') | |
Installs translations for a given locale. More... | |
install_translation ( $translation) | |
Downloads and installs the given translation. More... | |
is_transient_expired () | |
Determines if the cached TranslationsPress data needs refreshing. More... | |
refresh_all_translations () | |
Refreshes the cached TranslationsPress data, if expired. More... | |
set_all_translations () | |
Caches the TranslationsPress data, if not already cached. More... | |
should_install ( $translation, $locale='') | |
Determines if a translation should be installed. More... | |
site_transient_update_plugins ( $value) | |
Filters the translations transients to include the current plugin. More... | |
translations_api ( $result, $requested_type, $args) | |
Short-circuits translations API requests for private projects. More... | |
Static Public Member Functions | |
static | get_instance ( $slug, $translations_path='') |
Returns an instance of this class for the given slug. More... | |
Data Fields | |
const | T15S_API_EXPORT_URL = 'https://translationspress.com/app/gravitykit/{plugin_slug}/{language_slug}/default/export-translations' |
const | T15S_API_PACKAGES_URL = 'https://packages.translationspress.com/gravitykit/packages.json' |
const | T15S_TRANSIENT_EXPIRY = 12 * HOUR_IN_SECONDS |
const | T15S_TRANSIENT_KEY = 't15s-registry-gravitykit' |
Private Member Functions | |
__construct ( $slug, $translations_path='') | |
Class constructor. More... | |
Private Attributes | |
$_all_translations | |
$_slug = '' | |
$_translations_path = WP_LANG_DIR . '/plugins/' | |
Static Private Attributes | |
static | $_instances = [] |
Allows downloading and installing translations from TranslationsPress.
This is a modified version of the Gravity Forms' TranslationsPress_Updater class, which is based on the T15S library.
Definition at line 28 of file TranslationsPress_Updater.php.
|
private |
Class constructor.
string | $slug | The plugin slug. |
string | $translations_path | Translations storage path. |
Definition at line 78 of file TranslationsPress_Updater.php.
convert_po_to_json | ( | $po_file, | |
$json_file | |||
) |
Converts the PO file to JSON file by extracting only JavaScript translations.
string | $po_file | File with path to the PO file. |
string | $json_file | File with path where the JSON file will be saved. |
Exception |
Definition at line 457 of file TranslationsPress_Updater.php.
References TranslationsPress_Updater\get_exception().
Referenced by TranslationsPress_Updater\install_translation().
download_package | ( | $slug, | |
$locale = '' |
|||
) |
Downloads and installs the translations package for the specified plugin.
string | $slug | The plugin slug. |
string | $locale | The locale when the site locale is changed or an empty string to install all the user available locales. |
Exception |
Definition at line 304 of file TranslationsPress_Updater.php.
get_available_languages | ( | ) |
Returns an array of locales the site has installed.
Definition at line 542 of file TranslationsPress_Updater.php.
Referenced by TranslationsPress_Updater\should_install().
get_exception | ( | $message, | |
$method, | |||
$args | |||
) |
Formats and returns an exception message.
string | $message | Exception message with placeholders for sprintf() replacement. |
string | $method | Method throwing the exception. |
mixed | $args,... | Variable-length argument lists for sprintf() replacement. |
Definition at line 621 of file TranslationsPress_Updater.php.
References $args.
Referenced by TranslationsPress_Updater\convert_po_to_json(), TranslationsPress_Updater\get_remote_translations_data(), TranslationsPress_Updater\install(), and TranslationsPress_Updater\install_translation().
get_installed_translations | ( | $return_files = false | ) |
Returns an array of locales or .mo translation files found in the translations folder.
bool | $return_files | Indicates if the object should be keyed by locale (e.g., 'en_EN'). |
Definition at line 590 of file TranslationsPress_Updater.php.
Referenced by TranslationsPress_Updater\get_installed_translations_data().
get_installed_translations_data | ( | ) |
Returns header data from the installed translations for the current plugin.
Definition at line 559 of file TranslationsPress_Updater.php.
References TranslationsPress_Updater\$_slug, and TranslationsPress_Updater\get_installed_translations().
Referenced by TranslationsPress_Updater\should_install().
|
static |
Returns an instance of this class for the given slug.
string | $slug | The plugin slug. |
string | $translations_path | Translations storage path. |
Definition at line 102 of file TranslationsPress_Updater.php.
Referenced by Framework\get_T15s_updater().
get_plugin_translations | ( | ) |
Gets the TranslationsPress data for the current plugin.
Exception |
Definition at line 140 of file TranslationsPress_Updater.php.
References TranslationsPress_Updater\$_slug, and TranslationsPress_Updater\set_all_translations().
Referenced by TranslationsPress_Updater\install(), TranslationsPress_Updater\site_transient_update_plugins(), and TranslationsPress_Updater\translations_api().
get_remote_translations_data | ( | ) |
Gets the translation data from the TranslationsPress API.
Exception |
Definition at line 233 of file TranslationsPress_Updater.php.
References TranslationsPress_Updater\get_exception().
Referenced by TranslationsPress_Updater\set_all_translations().
get_slug_from_locale | ( | $locale | ) |
Returns T15S slug for the language based on the WP locale.
This is used to access the export URL (e.g., https://translationspress.com/app/gravitykit/gk-gravitycalendar/<slug>/default/export-translations/)
string | $locale | WP language locale. |
Definition at line 641 of file TranslationsPress_Updater.php.
References Arr\get().
Referenced by TranslationsPress_Updater\install_translation().
install | ( | $locale = '' | ) |
Installs translations for a given locale.
string | $locale | Locale for which to install the translation. |
Exception |
Definition at line 319 of file TranslationsPress_Updater.php.
References TranslationsPress_Updater\get_exception(), TranslationsPress_Updater\get_plugin_translations(), TranslationsPress_Updater\install_translation(), and TranslationsPress_Updater\should_install().
install_translation | ( | $translation | ) |
Downloads and installs the given translation.
array | $translation | The translation data. |
Exception |
Definition at line 353 of file TranslationsPress_Updater.php.
References TranslationsPress_Updater\convert_po_to_json(), TranslationsPress_Updater\get_exception(), and TranslationsPress_Updater\get_slug_from_locale().
Referenced by TranslationsPress_Updater\install().
is_transient_expired | ( | ) |
Determines if the cached TranslationsPress data needs refreshing.
Definition at line 218 of file TranslationsPress_Updater.php.
Referenced by TranslationsPress_Updater\set_all_translations().
refresh_all_translations | ( | ) |
Refreshes the cached TranslationsPress data, if expired.
Exception |
Definition at line 197 of file TranslationsPress_Updater.php.
References TranslationsPress_Updater\set_all_translations().
set_all_translations | ( | ) |
Caches the TranslationsPress data, if not already cached.
Exception |
Definition at line 274 of file TranslationsPress_Updater.php.
References TranslationsPress_Updater\get_remote_translations_data(), and TranslationsPress_Updater\is_transient_expired().
Referenced by TranslationsPress_Updater\get_plugin_translations(), and TranslationsPress_Updater\refresh_all_translations().
should_install | ( | $translation, | |
$locale = '' |
|||
) |
Determines if a translation should be installed.
array | $translation | The translation data. |
string | $locale | The locale when the site locale is changed or an empty string to check all the user available locales. |
Definition at line 514 of file TranslationsPress_Updater.php.
References TranslationsPress_Updater\get_available_languages(), and TranslationsPress_Updater\get_installed_translations_data().
Referenced by TranslationsPress_Updater\install(), and TranslationsPress_Updater\site_transient_update_plugins().
site_transient_update_plugins | ( | $value | ) |
Filters the translations transients to include the current plugin.
mixed | $value | The transient value. |
Exception |
Definition at line 159 of file TranslationsPress_Updater.php.
References TranslationsPress_Updater\$_slug, $value, TranslationsPress_Updater\get_plugin_translations(), and TranslationsPress_Updater\should_install().
translations_api | ( | $result, | |
$requested_type, | |||
$args | |||
) |
Short-circuits translations API requests for private projects.
bool | array | $result | The result object (default: false). |
string | $requested_type | The type of translations being requested. |
object | $args | Translation API arguments. |
Exception |
Definition at line 123 of file TranslationsPress_Updater.php.
References $args, and TranslationsPress_Updater\get_plugin_translations().
|
private |
Definition at line 60 of file TranslationsPress_Updater.php.
|
staticprivate |
Definition at line 67 of file TranslationsPress_Updater.php.
|
private |
Definition at line 44 of file TranslationsPress_Updater.php.
Referenced by TranslationsPress_Updater\get_installed_translations_data(), TranslationsPress_Updater\get_plugin_translations(), and TranslationsPress_Updater\site_transient_update_plugins().
|
private |
Definition at line 53 of file TranslationsPress_Updater.php.
const T15S_API_EXPORT_URL = 'https://translationspress.com/app/gravitykit/{plugin_slug}/{language_slug}/default/export-translations' |
Definition at line 35 of file TranslationsPress_Updater.php.
const T15S_API_PACKAGES_URL = 'https://packages.translationspress.com/gravitykit/packages.json' |
Definition at line 33 of file TranslationsPress_Updater.php.
const T15S_TRANSIENT_EXPIRY = 12 * HOUR_IN_SECONDS |
Definition at line 31 of file TranslationsPress_Updater.php.
const T15S_TRANSIENT_KEY = 't15s-registry-gravitykit' |
Definition at line 29 of file TranslationsPress_Updater.php.