PluginProbe
Gutenberg / 4.0.1
Gutenberg v4.0.1
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / i18n.php

i18n.php in Gutenberg 4.0.1, at lib/i18n.php

55 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Internationalization-related functions for the Gutenberg editor plugin.
4 *
5 * @package gutenberg
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 die( 'Silence is golden.' );
10 }
11
12 /**
13 * Returns Jed-formatted localization data.
14 *
15 * @since 0.1.0
16 *
17 * @param string $domain Translation domain.
18 *
19 * @return array
20 */
21 function gutenberg_get_jed_locale_data( $domain ) {
22 $translations = get_translations_for_domain( $domain );
23
24 $locale = array(
25 '' => array(
26 'domain' => $domain,
27 'lang' => is_admin() ? get_user_locale() : get_locale(),
28 ),
29 );
30
31 if ( ! empty( $translations->headers['Plural-Forms'] ) ) {
32 $locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
33 }
34
35 foreach ( $translations->entries as $msgid => $entry ) {
36 $locale[ $msgid ] = $entry->translations;
37 }
38
39 return $locale;
40 }
41
42 /**
43 * Load plugin text domain for translations.
44 *
45 * @since 0.1.0
46 */
47 function gutenberg_load_plugin_textdomain() {
48 load_plugin_textdomain(
49 'gutenberg',
50 false,
51 plugin_basename( gutenberg_dir_path() ) . '/languages/'
52 );
53 }
54 add_action( 'plugins_loaded', 'gutenberg_load_plugin_textdomain' );
55