WordPress.org

Ready to get started?Download WordPress

Forums

UK Cookie Consent
Translation of custom srtings (6 posts)

  1. anoriell
    Member
    Posted 1 year ago #

    Hello
    I installed your plugin and set custom text messages that appear on my page.
    I noticed that I can't translate them with WPML String Translation and I managed to fix it by changing one line in the plugin.

    I changed:

    $content = sprintf( '<div id="catapult-cookie-bar">%s<button id="catapultCookie" tabindex=1 onclick="catapultAcceptCookies();">%s</button><a tabindex=1 href="%s">%s</a></div>', htmlspecialchars( $current_text ), htmlspecialchars( $accept_text ), home_url( $link_text ), htmlspecialchars( $more_text ) );

    to:

    $content = sprintf( '<div id="catapult-cookie-bar">%s<button id="catapultCookie" tabindex=1 onclick="catapultAcceptCookies();">%s</button><a tabindex=1 href="%s">%s</a></div>', htmlspecialchars( __($current_text,'uk-cookie-consent') ), htmlspecialchars( __($accept_text,'uk-cookie-consent') ), home_url( __($link_text,'uk-cookie-consent') ), htmlspecialchars( __($more_text,'uk-cookie-consent') ) );

    So basically I added __() function to every custom string. Could you do the same in your official version of this plugin?

    I would like to install your plugin on about 10 pages and it would be really helpful if I didn't have to change this one line on every plugin update.

    Thanks a lot in advance!

    http://wordpress.org/extend/plugins/uk-cookie-consent/

  2. fiterix
    Member
    Posted 1 year ago #

    Anoriell, can You tell me what should I do to translate messages from this plugin with WPML?
    I already edited uk-cookie-consent.php and i don't know what to do next...

  3. anoriell
    Member
    Posted 1 year ago #

    fiterix, you have to have WPML String Translation installed.

    Then you go to WPML->String Translation (the last position in menu) -> you choose uk-cookie-consent from the second select list at the top of the page.

    And now underneath you should see phrases than can be translated :)

  4. fiterix
    Member
    Posted 1 year ago #

    thanks! I've already checked this before, but the problem is that i haven't uk-cookie-consent position on this list... :|

  5. anoriell
    Member
    Posted 1 year ago #

    Ok, so maybe try to go to WPML->Theme localization find UK Cookie on the plugin list at the bottom of the page, check it and click 'scan for...' button.

    uk-cookie-consent position should appear in WPML->String Translation.

    If not... Well you can also try to go to WPML->String Translation and check "Auto-register strings always" option at the bottom of the page.

    Let me know if it worked...

  6. Josep Comas
    Member
    Posted 6 months ago #

    Other option:

    For WPML, you create a file named "wpml-config.xml" in "uk-cookie-consent" plugin directory with following code:

    <wpml-config>
        <admin-texts>
            <key name="catapult_cookie_options">
                <key name="catapult_cookie_text_settings" />
                <key name="catapult_cookie_accept_settings" />
                <key name="catapult_cookie_more_settings" />
    	    <key name="catapult_cookie_link_settings" />
            </key>
        </admin-texts>
    </wpml-config>

    And then you go to WPML->String Translation and translate according your language.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.