WordPress.org

Make WordPress Core

Changeset 43759


Ignore:
Timestamp:
10/19/2018 05:51:07 AM (13 months ago)
Author:
pento
Message:

i18n: Add the wp_get_jed_locale_data() function.

This function formats locale information to be used by Jed.

Props desrosj.
See #45111.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/l10n.php

    r41734 r43759  
    13331333    return $wp_locale_switcher->is_switched();
    13341334}
     1335
     1336/**
     1337 * Returns Jed-formatted localization data.
     1338 *
     1339 * @since 5.0.0
     1340 *
     1341 * @param string $domain Translation domain.
     1342 * @return array Jed-formatted localization data.
     1343 */
     1344function wp_get_jed_locale_data( $domain ) {
     1345    $translations = get_translations_for_domain( $domain );
     1346
     1347    $locale = array(
     1348        '' => array(
     1349            'domain' => $domain,
     1350            'lang'   => is_admin() ? get_user_locale() : get_locale(),
     1351        ),
     1352    );
     1353
     1354    if ( ! empty( $translations->headers['Plural-Forms'] ) ) {
     1355        $locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
     1356    }
     1357
     1358    foreach ( $translations->entries as $msgid => $entry ) {
     1359        $locale[ $msgid ] = $entry->translations;
     1360    }
     1361
     1362    return $locale;
     1363}
Note: See TracChangeset for help on using the changeset viewer.