Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem: I want to translate WP Front Notification popup and buttons/links

Solution: currently, WP Front Notification isn't fully compatible with WPML but you can tweak the code to translate the popup and the buttons. See the 2 links below, in the first one you can find instruction for the popup, in the second for the buttons

Relevant Documentation: https://wpml.org/forums/topic/translation-of-wpfront-notification-bar-plugin/ https://wpml.org/forums/topic/wp-front-notification-not-translatable/#post-3640699

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 5 replies, has 2 voices.

Last updated by julianZ-4 2 years, 7 months ago.

Assigned support staff: Laura.

Author Posts
April 16, 2019 at 2:23 pm #3622923

julianZ-4

I am trying to: Use WP Front Notifications in more than one language

I expected to see: That I be able to translate WP Front Notification in String translation, that did not work.

Instead, I got: Always the not translated text.

I already found this support thread: https://wpml.org/forums/topic/translation-of-wpfront-notification-bar-plugin/

I used that solution to be able to translate the notification text. That worked. But I also would like to translate the button-text and button-url.

Can you please help and tell me which changes I need to make?

April 17, 2019 at 1:25 pm #3631163

Laura
Supporter

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hi,

thanks for contacting us.

Probably you'll need to add the other texts you need to register them as well in the xml-config file.
To do that, you have first to find their name.

Please do as it follows:
- go to WPML -> String Translation
- go to the string admin page (link at the bottom of the page)
- open the source code (CTRL+U)
- search for the texts you need to translate
- probably they're under the domain "wpfront-notification-bar-options"
- once you've find them, add them to the xml-config file; if they're under "wpfront-notification-bar-options" you will only need to add

 <key name="youroptionname" />

, otherwise you'll need to add a key name too.

For more information, please look at this: https://wpml.org/documentation/support/language-configuration-files/#admin-texts

Let me know if this helps you or if you need further assistance.

April 17, 2019 at 4:14 pm #3632637

julianZ-4

Thanks Laura. I did that, but I think the step with the edit of the template.php file of the tutorial is missing. So no change at the moment - I see these variables under String Translations. They are translated. But in the frontend, it always shows the original language.

Can you please tell me what I have to change in the template.php of the plugin? I tried myself without luck..

This is my new config xml:

<wpml-config>
    <admin-texts>
        <key name="wpfront-notification-bar-options">
            <key name="message" />
            <key name="button_action_url" />
            <key name="button_text" />
        </key>
    </admin-texts>
</wpml-config>

April 18, 2019 at 3:49 pm #3640511

Laura
Supporter

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hi,

please try to add 2 snippet like this one (you should already have added it)

<?php
    echo apply_filters( 'wpml_translate_single_string', $this->options->message(), 'admin_texts_wpfront-notification-bar-options', '[wpfront-notification-bar-options]KEYNAME', apply_filters( 'wpml_current_language', NULL ) );
?>

just change KEYNAME with the new keys you registered.

April 18, 2019 at 3:54 pm #3640521

julianZ-4

Hi Laura

It seems to be a different format.

Please find the contents of the notification-bar-template.php here:

<?php
/*
  WPFront Notification Bar Plugin
  Copyright (C) 2013, WPFront.com
  Website: wpfront.com
  Contact: syam@wpfront.com

  WPFront Notification Bar Plugin is distributed under the GNU General Public License, Version 3,
  June 2007. Copyright (C) 2007 Free Software Foundation, Inc., 51 Franklin
  St, Fifth Floor, Boston, MA 02110, USA

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * Template for WPFront Notification Bar
 *
 * @author Syam Mohan <syam@wpfront.com>
 * @copyright 2013 WPFront.com
 */
?>

<style type="text/css">
    #wpfront-notification-bar 
    {
        background: <?php echo $this->options->bar_from_color(); ?>;
        background: -moz-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%, <?php echo $this->options->bar_to_color(); ?> 100%);
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,<?php echo $this->options->bar_from_color(); ?>), color-stop(100%,<?php echo $this->options->bar_to_color(); ?>));
        background: -webkit-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
        background: -o-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
        background: -ms-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
        background: linear-gradient(to bottom, <?php echo $this->options->bar_from_color(); ?> 0%, <?php echo $this->options->bar_to_color(); ?> 100%);
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<?php echo $this->options->bar_from_color(); ?>', endColorstr='<?php echo $this->options->bar_to_color(); ?>',GradientType=0 );
    }

    #wpfront-notification-bar div.wpfront-message
    {
        color: <?php echo $this->options->message_color(); ?>;
    }

    #wpfront-notification-bar a.wpfront-button
    {
        background: <?php echo $this->options->button_from_color(); ?>;
        background: -moz-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%, <?php echo $this->options->button_to_color(); ?> 100%);
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,<?php echo $this->options->button_from_color(); ?>), color-stop(100%,<?php echo $this->options->button_to_color(); ?>));
        background: -webkit-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
        background: -o-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
        background: -ms-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
        background: linear-gradient(to bottom, <?php echo $this->options->button_from_color(); ?> 0%, <?php echo $this->options->button_to_color(); ?> 100%);
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<?php echo $this->options->button_from_color(); ?>', endColorstr='<?php echo $this->options->button_to_color(); ?>',GradientType=0 );

        color: <?php echo $this->options->button_text_color(); ?>;
    }

    #wpfront-notification-bar-open-button
    {
        background-color: <?php echo $this->options->open_button_color(); ?>;
    }

    #wpfront-notification-bar  div.wpfront-close 
    {
        border: 1px solid <?php echo $this->options->close_button_color(); ?>;
        background-color: <?php echo $this->options->close_button_color(); ?>;
        color: <?php echo $this->options->close_button_color_x(); ?>;
    }

    #wpfront-notification-bar  div.wpfront-close:hover 
    {
        border: 1px solid <?php echo $this->options->close_button_color_hover(); ?>;
        background-color: <?php echo $this->options->close_button_color_hover(); ?>;
    }
</style>

<?php if ($this->options->display_button() && $this->options->button_action() == 2) { ?>
    <script type="text/javascript">
        function wpfront_notification_bar_button_action_script() {
            try {
    <?php echo $this->options->button_action_javascript(); ?>
            }
            catch (err) {
            }
        }
    </script>
<?php } ?>

<div id="wpfront-notification-bar-spacer"  style="display: none;">
    <div id="wpfront-notification-bar-open-button" class="<?php echo $this->options->position() == 1 ? 'top wpfront-bottom-shadow' : 'bottom wpfront-top-shadow'; ?>"></div>
    <div id="wpfront-notification-bar" class="wpfront-fixed <?php if ($this->options->display_shadow()) echo $this->options->position() == 1 ? 'wpfront-bottom-shadow' : 'wpfront-top-shadow'; ?>">
        <?php if ($this->options->close_button()) { ?>
            <div class="wpfront-close">X</div>
        <?php } ?>
        <table border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td>
<div class="wpfront-message">
<?php
    echo apply_filters( 'wpml_translate_single_string', $this->options->message(), 'admin_texts_wpfront-notification-bar-options', '[wpfront-notification-bar-options]message', apply_filters( 'wpml_current_language', NULL ) );
?>
</div>
                    <div>
                        <?php 
                            if ($this->options->display_button()) { 
                                $button_text = $this->get_button_text();
                                ?>
                                <?php if ($this->options->button_action() == 1) { ?>
                                    <a class="wpfront-button" href="<?php echo $this->options->button_action_url(); ?>"  target="<?php echo $this->options->button_action_new_tab() ? '_blank' : '_self'; ?>" <?php echo $this->options->button_action_url_nofollow() ? 'rel="nofollow"' : ''; ?>><?php echo $button_text; ?></a>
                                <?php } ?>
                                <?php if ($this->options->button_action() == 2) { ?>
                                    <a class="wpfront-button" onclick="javascript:wpfront_notification_bar_button_action_script();"><?php echo $button_text; ?></a>
                                <?php } ?>
                        <?php } ?>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>


<style type="text/css">
<?php echo $this->options->custom_css(); ?>
</style>

Can you please tell me where to change what?

April 18, 2019 at 4:11 pm #3640699

julianZ-4

My issue is resolved now. Thank you!

For everyone who wants to know how:


<?php
/*
  WPFront Notification Bar Plugin
  Copyright (C) 2013, WPFront.com
  Website: wpfront.com
  Contact: syam@wpfront.com

  WPFront Notification Bar Plugin is distributed under the GNU General Public License, Version 3,
  June 2007. Copyright (C) 2007 Free Software Foundation, Inc., 51 Franklin
  St, Fifth Floor, Boston, MA 02110, USA

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * Template for WPFront Notification Bar
 *
 * @author Syam Mohan <syam@wpfront.com>
 * @copyright 2013 WPFront.com
 */
?>

<style type="text/css">
    #wpfront-notification-bar 
    {
        background: <?php echo $this->options->bar_from_color(); ?>;
        background: -moz-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%, <?php echo $this->options->bar_to_color(); ?> 100%);
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,<?php echo $this->options->bar_from_color(); ?>), color-stop(100%,<?php echo $this->options->bar_to_color(); ?>));
        background: -webkit-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
        background: -o-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
        background: -ms-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
        background: linear-gradient(to bottom, <?php echo $this->options->bar_from_color(); ?> 0%, <?php echo $this->options->bar_to_color(); ?> 100%);
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<?php echo $this->options->bar_from_color(); ?>', endColorstr='<?php echo $this->options->bar_to_color(); ?>',GradientType=0 );
    }

    #wpfront-notification-bar div.wpfront-message
    {
        color: <?php echo $this->options->message_color(); ?>;
    }

    #wpfront-notification-bar a.wpfront-button
    {
        background: <?php echo $this->options->button_from_color(); ?>;
        background: -moz-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%, <?php echo $this->options->button_to_color(); ?> 100%);
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,<?php echo $this->options->button_from_color(); ?>), color-stop(100%,<?php echo $this->options->button_to_color(); ?>));
        background: -webkit-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
        background: -o-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
        background: -ms-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
        background: linear-gradient(to bottom, <?php echo $this->options->button_from_color(); ?> 0%, <?php echo $this->options->button_to_color(); ?> 100%);
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<?php echo $this->options->button_from_color(); ?>', endColorstr='<?php echo $this->options->button_to_color(); ?>',GradientType=0 );

        color: <?php echo $this->options->button_text_color(); ?>;
    }

    #wpfront-notification-bar-open-button
    {
        background-color: <?php echo $this->options->open_button_color(); ?>;
    }

    #wpfront-notification-bar  div.wpfront-close 
    {
        border: 1px solid <?php echo $this->options->close_button_color(); ?>;
        background-color: <?php echo $this->options->close_button_color(); ?>;
        color: <?php echo $this->options->close_button_color_x(); ?>;
    }

    #wpfront-notification-bar  div.wpfront-close:hover 
    {
        border: 1px solid <?php echo $this->options->close_button_color_hover(); ?>;
        background-color: <?php echo $this->options->close_button_color_hover(); ?>;
    }
</style>

<?php if ($this->options->display_button() && $this->options->button_action() == 2) { ?>
    <script type="text/javascript">
        function wpfront_notification_bar_button_action_script() {
            try {
    <?php echo $this->options->button_action_javascript(); ?>
            }
            catch (err) {
            }
        }
    </script>
<?php } ?>

<div id="wpfront-notification-bar-spacer"  style="display: none;">
    <div id="wpfront-notification-bar-open-button" class="<?php echo $this->options->position() == 1 ? 'top wpfront-bottom-shadow' : 'bottom wpfront-top-shadow'; ?>"></div>
    <div id="wpfront-notification-bar" class="wpfront-fixed <?php if ($this->options->display_shadow()) echo $this->options->position() == 1 ? 'wpfront-bottom-shadow' : 'wpfront-top-shadow'; ?>">
        <?php if ($this->options->close_button()) { ?>
            <div class="wpfront-close">X</div>
        <?php } ?>
        <table border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td>
<div class="wpfront-message">
<?php
    echo apply_filters( 'wpml_translate_single_string', $this->options->message(), 'admin_texts_wpfront-notification-bar-options', '[wpfront-notification-bar-options]message', apply_filters( 'wpml_current_language', NULL ) );
?>
</div>
                    <div>
                        <?php 
                            if ($this->options->display_button()) { 
                                $button_text = apply_filters( 'wpml_translate_single_string', $this->get_button_text(), 'admin_texts_wpfront-notification-bar-options', '[wpfront-notification-bar-options]button_text', apply_filters( 'wpml_current_language', NULL ) );
                                ?>
                                <?php if ($this->options->button_action() == 1) { ?>
                                    <a class="wpfront-button" href="<?php echo apply_filters( 'wpml_translate_single_string', $this->options->button_action_url(), 'admin_texts_wpfront-notification-bar-options', '[wpfront-notification-bar-options]button_action_url', apply_filters( 'wpml_current_language', NULL ) );



                                     ?>"  target="<?php echo $this->options->button_action_new_tab() ? '_blank' : '_self'; ?>" <?php echo $this->options->button_action_url_nofollow() ? 'rel="nofollow"' : ''; ?>><?php echo $button_text; ?></a>
                                <?php } ?>
                                <?php if ($this->options->button_action() == 2) { ?>
                                    <a class="wpfront-button" onclick="javascript:wpfront_notification_bar_button_action_script();"><?php echo $button_text; ?></a>
                                <?php } ?>
                        <?php } ?>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>


<style type="text/css">
<?php echo $this->options->custom_css(); ?>
</style>