css
5 years ago
js
5 years ago
capabilities.php
7 years ago
config-validator.php
5 years ago
contact-form-functions.php
5 years ago
contact-form-template.php
6 years ago
contact-form.php
5 years ago
controller.php
7 years ago
form-tag.php
5 years ago
form-tags-manager.php
6 years ago
formatting.php
5 years ago
functions.php
5 years ago
integration.php
7 years ago
l10n.php
7 years ago
mail.php
5 years ago
pipe.php
5 years ago
rest-api.php
5 years ago
shortcodes.php
9 years ago
special-mail-tags.php
5 years ago
submission.php
5 years ago
upgrade.php
7 years ago
validation.php
7 years ago
l10n.php
99 lines
| 1 | <?php |
| 2 | |
| 3 | function wpcf7_l10n() { |
| 4 | static $l10n = array(); |
| 5 | |
| 6 | if ( ! empty( $l10n ) ) { |
| 7 | return $l10n; |
| 8 | } |
| 9 | |
| 10 | if ( ! is_admin() ) { |
| 11 | return $l10n; |
| 12 | } |
| 13 | |
| 14 | require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
| 15 | |
| 16 | $api = translations_api( 'plugins', array( |
| 17 | 'slug' => 'contact-form-7', |
| 18 | 'version' => WPCF7_VERSION, |
| 19 | ) ); |
| 20 | |
| 21 | if ( is_wp_error( $api ) |
| 22 | or empty( $api['translations'] ) ) { |
| 23 | return $l10n; |
| 24 | } |
| 25 | |
| 26 | foreach ( (array) $api['translations'] as $translation ) { |
| 27 | if ( ! empty( $translation['language'] ) |
| 28 | and ! empty( $translation['english_name'] ) ) { |
| 29 | $l10n[$translation['language']] = $translation['english_name']; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | return $l10n; |
| 34 | } |
| 35 | |
| 36 | function wpcf7_is_valid_locale( $locale ) { |
| 37 | $pattern = '/^[a-z]{2,3}(?:_[a-zA-Z_]{2,})?$/'; |
| 38 | return (bool) preg_match( $pattern, $locale ); |
| 39 | } |
| 40 | |
| 41 | function wpcf7_is_rtl( $locale = '' ) { |
| 42 | static $rtl_locales = array( |
| 43 | 'ar' => 'Arabic', |
| 44 | 'ary' => 'Moroccan Arabic', |
| 45 | 'azb' => 'South Azerbaijani', |
| 46 | 'fa_IR' => 'Persian', |
| 47 | 'haz' => 'Hazaragi', |
| 48 | 'he_IL' => 'Hebrew', |
| 49 | 'ps' => 'Pashto', |
| 50 | 'ug_CN' => 'Uighur', |
| 51 | ); |
| 52 | |
| 53 | if ( empty( $locale ) |
| 54 | and function_exists( 'is_rtl' ) ) { |
| 55 | return is_rtl(); |
| 56 | } |
| 57 | |
| 58 | if ( empty( $locale ) ) { |
| 59 | $locale = get_locale(); |
| 60 | } |
| 61 | |
| 62 | return isset( $rtl_locales[$locale] ); |
| 63 | } |
| 64 | |
| 65 | function wpcf7_load_textdomain( $locale = null ) { |
| 66 | global $l10n; |
| 67 | |
| 68 | $domain = 'contact-form-7'; |
| 69 | |
| 70 | if ( ( is_admin() ? get_user_locale() : get_locale() ) === $locale ) { |
| 71 | $locale = null; |
| 72 | } |
| 73 | |
| 74 | if ( empty( $locale ) ) { |
| 75 | if ( is_textdomain_loaded( $domain ) ) { |
| 76 | return true; |
| 77 | } else { |
| 78 | return load_plugin_textdomain( $domain, false, $domain . '/languages' ); |
| 79 | } |
| 80 | } else { |
| 81 | $mo_orig = $l10n[$domain]; |
| 82 | unload_textdomain( $domain ); |
| 83 | |
| 84 | $mofile = $domain . '-' . $locale . '.mo'; |
| 85 | $path = WP_PLUGIN_DIR . '/' . $domain . '/languages'; |
| 86 | |
| 87 | if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) ) { |
| 88 | return $loaded; |
| 89 | } else { |
| 90 | $mofile = WP_LANG_DIR . '/plugins/' . $mofile; |
| 91 | return load_textdomain( $domain, $mofile ); |
| 92 | } |
| 93 | |
| 94 | $l10n[$domain] = $mo_orig; |
| 95 | } |
| 96 | |
| 97 | return false; |
| 98 | } |
| 99 |