• Resolved edeb

    (@edeb)


    I added new custom fields to woocommerce like the following:

    add_filter( 'woocommerce_checkout_fields' , 'bones_add_field_and_reorder_fields', 99 );
    
    function bones_add_field_and_reorder_fields( $fields ) {
    
        // Add New Fields
        $fields['billing']['billing_address_1'] = array(
            'label'     => __('Street address', 'naifcarecom2'),
            'placeholder'   => _x('', 'placeholder', 'naifcarecom2'),
            'required'  => true,
            'class'     => array('form-row-first'),
            'clear'     => true
        );
    
        $fields['billing']['billing_houseno'] = array(
            'label'     => __('House number', 'naifcarecom2'),
            'placeholder'  => _x('', 'placeholder', 'naifcarecom2'),
            'required'  => true,
            'class'     => array('form-row-last'),
            'clear'     => true
        );
    }

    The very weird thing is that “House number” is correctly synced and I can find it in Loco > Themes > MyTheme > nl_NL.po while the first one not. So I can translate just one of those.

    Can you help?
    Note. To replicate the issue you just need to add something to the cart and go to the checkout. It’s all Dutch but you’ll see the english string.

    • This topic was modified 5 years, 10 months ago by edeb.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Tim W

    (@timwhitlock)

    I’m not familiar with WooCommerce custom fields, but check these labels are actually being pulled from your translation files, and not being saved somewhere into your database.

    Loco Translate saves strings into MO files. If these strings are present and the file is being loaded then it’s job is complete and the rest is up to you. How you use your strings for purposes like custom fields isn’t something I can provide support for.

    Thread Starter edeb

    (@edeb)

    So those strings are not saved in the database. I don’t know if it’s a configuration issue or something going wrong with my theme.

    For what I know about gettext once I inserted a new string in theme files, that should appear in my Loco theme file as well, ready to be translated.

    So any help would be highly appreciated.

    Thanks.

    • This reply was modified 5 years, 10 months ago by edeb.
    Plugin Author Tim W

    (@timwhitlock)

    It seems to me that your problem is two-fold:

    1. You’ve confused yourself by duplicating your theme from “naifcarecom” to “naifcarecom2” and have updated the wrong files. Your active theme is “naifcarecom2” but declares its text domain as “naifcarecom”.

    2. You haven’t synced your code changes (it’s not automatic). As your theme has a template (POT) file, this should be synced to the source code. Then your PO synced from that. Do this AFTER you’ve corrected the error above.

    naifcarecom POT file (2014-11-18):
    https://naifcare.com/wp-content/themes/naifcarecom/languages/naifcarecom.pot

    naifcarecom Dutch PO file (updated by Eliza YESTERDAY)
    https://naifcare.com/wp-content/themes/naifcarecom/languages/nl_NL.po

    naifcarecom2: POT file (2018-06-21)
    https://naifcare.com/wp-content/themes/naifcarecom2/languages/naifcarecom2.pot

    naifcarecom2: Dutch PO file (Updated by Sjoerd 2018-10-23)
    https://naifcare.com/wp-content/themes/naifcarecom2/languages/nl_NL.po

    In summary: you updated files in an old theme from an old translation template.

    Do this:

    1. Fix the Text Domain error in style.css to use the correct one.
    2. Sync your naifcarecom2.pot file with your code changes.
    3. Sync your Dutch PO file to the correct POT file.
    4. Translate the “Street address” text which should now appear.

    Thread Starter edeb

    (@edeb)

    Got it. So you’re saying that Loco doesn’t generate the .pot file automatically?

    Plugin Author Tim W

    (@timwhitlock)

    Correct.

    Thread Starter edeb

    (@edeb)

    So the problem here, besides what you suggested, was that didn’t sync at all the .pot file. We fixed deleting and re-syncing it, probably some cache related issue.

    Plugin Author Tim W

    (@timwhitlock)

    I don’t see how caching of any kind would prevent the manual Sync operation from working. You have to click Save from the editor when you update your POT. This is a POST request, so caches should not apply.

    Thanks for marking as resolved.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Woocommerce not synced correctly’ is closed to new replies.