GV_Calendar_Translations
Supplies every string FullCalendar shows from the plugin's text domain, in the language of the
calendar's Localization setting, which can differ from the site's. The render script builds a
FullCalendar locale object from it with wp.i18n.createI18n(). Text direction and week numbering
also come from here; the first day of the week comes from WordPress.
Since: 2.25.0
Source: includes/class-calendar-translations.php:20
Details
- Kind:
class - Namespace:
(global)
Methods
| Method | Description |
|---|---|
get_string_definitions() | Returns the strings FullCalendar shows, keyed by the name the render script uses for each. |
get_locale_payload() | Returns what the render script needs to show a calendar in one language. |
get_locale_data() | Returns the calendar strings' translations in Jed format, for wp.i18n.createI18n(). |
get_translations() | Returns the plugin's translations for a language without changing the language of the request. |
get_wp_locale() | Returns the WordPress locale for a FullCalendar locale code. |
get_direction() | Returns the text direction of a language. |
schedule_language_install() | Schedules installing the plugin's translations for every language a calendar is set to. |
install_calendar_languages() | Installs or updates the plugin's translations for every language a calendar is set to. |
Method Reference
get_string_definitions()
public static function get_string_definitions()
Returns the strings FullCalendar shows, keyed by the name the render script uses for each.
Every string is written as source text here so it is extracted into translations.pot. Plurals use
_n_noop(); the render script picks the right form for each count.
Returns
array<string,— array{single: string, plural?: string, context?: string}>
Since: 2.25.0
Source: includes/class-calendar-translations.php:102
get_locale_payload()
public static function get_locale_payload( $fc_locale )
Returns what the render script needs to show a calendar in one language.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$fc_locale | string | FullCalendar locale code from the calendar's Localization setting. Empty means the setting was never saved; the strings then follow the site language. |
Returns
array{code:— string, direction: string, week: array{doy: int}, strings: array, locale_data: array}
Since: 2.25.0
Source: includes/class-calendar-translations.php:210
get_locale_data()
public static function get_locale_data( $wp_locale )
Returns the calendar strings' translations in Jed format, for wp.i18n.createI18n().
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$wp_locale | string | WordPress locale. Empty or English returns no translations. |
Returns
array— Jed locale data, with only the header when there is no translation.
Since: 2.25.0
Source: includes/class-calendar-translations.php:231
get_translations()
public static function get_translations( $wp_locale )
Returns the plugin's translations for a language without changing the language of the request.
Reads, in order of precedence: a custom translation saved by Loco Translate, one in wp-content/languages/plugins, and the language pack installed from the GravityKit translation platform. For the request's own language, the loaded text domain is used, so every change a site makes to it applies.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$wp_locale | string | WordPress locale, such as fr_FR. |
Returns
Translations|WP_Translations|null— Null when the language is English or has no translation.
Since: 2.25.0
Source: includes/class-calendar-translations.php:289
get_wp_locale()
public static function get_wp_locale( $fc_locale )
Returns the WordPress locale for a FullCalendar locale code.
A FullCalendar locale with no WordPress equivalent, such as Arabic (Kuwait), uses its base language's.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$fc_locale | string | FullCalendar locale code. |
Returns
string— Empty when WordPress has no matching locale.
Since: 2.25.0
Source: includes/class-calendar-translations.php:403
get_direction()
public static function get_direction( $locale )
Returns the text direction of a language.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$locale | string | FullCalendar or WordPress locale code. |
Returns
string— 'rtl' or 'ltr'.
Since: 2.25.0
Source: includes/class-calendar-translations.php:449
schedule_language_install()
public static function schedule_language_install( $force=false )
Schedules installing the plugin's translations for every language a calendar is set to.
Foundation installs translations for the site's and the user's language only, so a calendar in another language would otherwise show English text. Runs in wp-admin for users who can install languages, at most twice a day, and whenever a calendar's settings are saved. The downloads run in a scheduled event, so a slow translation server never holds up the page.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$force | bool | false | Skip the twice-a-day limit. |
Returns
bool— Whether the install was scheduled.
Since: 2.25.0
Source: includes/class-calendar-translations.php:469
install_calendar_languages()
public static function install_calendar_languages()
Installs or updates the plugin's translations for every language a calendar is set to.
Runs from the event schedule_language_install() schedules, which checked the user's permission.
Returns
string[]— WordPress locales whose translations were checked.
Since: 2.25.0
Source: includes/class-calendar-translations.php:498