• For language shorcode, i wanted to share the changed code to support opensource work.

    here is the function change in special-mail-tags.php

    It allows you to use [_lang] tag in email, so output browser accepted language, used in localized response.

    function wpcf7_special_mail_tag( $output, $name ) {

    // For backwards compat.
    $name = preg_replace( ‘/^wpcf7\./’, ‘_’, $name );

    if ( ‘_remote_ip’ == $name )
    $output = preg_replace( ‘/[^0-9a-f.:, ]/’, ”, $_SERVER[‘REMOTE_ADDR’] );

    elseif ( ‘_url’ == $name ) {
    $url = untrailingslashit( home_url() );
    $url = preg_replace( ‘%(?<!:|/)/.*$%’, ”, $url );
    $url .= wpcf7_get_request_uri();
    $output = esc_url( $url );
    }

    elseif ( ‘_date’ == $name )
    $output = date_i18n( get_option( ‘date_format’ ) );

    elseif ( ‘_time’ == $name )
    $output = date_i18n( get_option( ‘time_format’ ) );

    elseif ( ‘_lang’ == $name ) {
    $code = substr($_SERVER[‘HTTP_ACCEPT_LANGUAGE’],0,2);
    $langs = array (
    “ab” => “Abkhazian”,
    “af” => “Afrikaans”,
    “an” => “Aragonese”,
    “ar” => “Arabic”,
    “as” => “Assamese”,
    “az” => “Azerbaijani”,
    “be” => “Belarusian”,
    “bg” => “Bulgarian”,
    “bn” => “Bengali”,
    “bo” => “Tibetan”,
    “br” => “Breton”,
    “bs” => “Bosnian”,
    “ca” => “Catalan / Valencian”,
    “ce” => “Chechen”,
    “co” => “Corsican”,
    “cs” => “Czech”,
    “cu” => “Church Slavic”,
    “cy” => “Welsh”,
    “da” => “Danish”,
    “de” => “German”,
    “el” => “Greek”,
    “en” => “English”,
    “eo” => “Esperanto”,
    “es” => “Spanish / Castilian”,
    “et” => “Estonian”,
    “eu” => “Basque”,
    “fa” => “Persian”,
    “fi” => “Finnish”,
    “fj” => “Fijian”,
    “fo” => “Faroese”,
    “fr” => “French”,
    “fy” => “Western Frisian”,
    “ga” => “Irish”,
    “gd” => “Gaelic / Scottish Gaelic”,
    “gl” => “Galician”,
    “gv” => “Manx”,
    “he” => “Hebrew”,
    “hi” => “Hindi”,
    “hr” => “Croatian”,
    “ht” => “Haitian; Haitian Creole”,
    “hu” => “Hungarian”,
    “hy” => “Armenian”,
    “id” => “Indonesian”,
    “is” => “Icelandic”,
    “it” => “Italian”,
    “ja” => “Japanese”,
    “jv” => “Javanese”,
    “ka” => “Georgian”,
    “kg” => “Kongo”,
    “ko” => “Korean”,
    “ku” => “Kurdish”,
    “kw” => “Cornish”,
    “ky” => “Kirghiz”,
    “la” => “Latin”,
    “lb” => “Luxembourgish Letzeburgesch”,
    “li” => “Limburgan Limburger Limburgish”,
    “ln” => “Lingala”,
    “lt” => “Lithuanian”,
    “lv” => “Latvian”,
    “mg” => “Malagasy”,
    “mk” => “Macedonian”,
    “mn” => “Mongolian”,
    “mo” => “Moldavian”,
    “ms” => “Malay”,
    “mt” => “Maltese”,
    “my” => “Burmese”,
    “nb” => “Norwegian (Bokmål)”,
    “ne” => “Nepali”,
    “nl” => “Dutch”,
    “nn” => “Norwegian (Nynorsk)”,
    “no” => “Norwegian”,
    “oc” => “Occitan (post 1500); Provençal”,
    “pl” => “Polish”,
    “pt” => “Portuguese”,
    “rm” => “Raeto-Romance”,
    “ro” => “Romanian”,
    “ru” => “Russian”,
    “sc” => “Sardinian”,
    “se” => “Northern Sami”,
    “sk” => “Slovak”,
    “sl” => “Slovenian”,
    “so” => “Somali”,
    “sq” => “Albanian”,
    “sr” => “Serbian”,
    “sv” => “Swedish”,
    “sw” => “Swahili”,
    “tk” => “Turkmen”,
    “tr” => “Turkish”,
    “ty” => “Tahitian”,
    “uk” => “Ukrainian”,
    “ur” => “Urdu”,
    “uz” => “Uzbek”,
    “vi” => “Vietnamese”,
    “vo” => “Volapuk”,
    “yi” => “Yiddish”,
    “zh” => “Chinese”);
    $output = $langs[$code];
    }
    elseif ( ‘_country’ == $name ) {
    global $VisitorCountry;
    $output = $VisitorCountry->GetName();
    }

    return $output;
    }

    http://wordpress.org/extend/plugins/contact-form-7/

  • The topic ‘[Solved] Browser Language shortcode for Localized response’ is closed to new replies.