• Resolved Aarón

    (@aaronfc)


    Hi,
    I’m a developer at Automattic and we have been investigating an issue reported by a user with one of our plugins (WooCommerce Paid Courses for Sensei) and Loco Translate.

    Basically we are packaging our plugin in a way that makes this check here fail so the translation JSON files are not generated.

    We were wondering if it would be possible to have some filter so that we can skip that file check. We have done some tests with that check disabled and everything worked for us.

    Another alternative is maybe having some filter not for skipping the check but to be able to “fix” the route for Loco Translate. We can’t use load_script_textdomain_relative_path because we need that to return the “fake” path so we generate the same md5 and are able to use the same translations.

    Let us know what you think on this or any other alternatives.

    Thanks for your help!

    • This topic was modified 2 years, 3 months ago by Aarón.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Tim W

    (@timwhitlock)

    I’d be open to a loco_* filter that effectively wraps the load_script_textdomain_relative_path filter and encapsulates the file check at the same time, such that a non-existent path could be returned.

    I’m too busy to do this very quickly, but I will add it to the todo list for the next release. If you’re in a hurry then feel free to propose your preferred solution as long as you feel it would be useful for similar use cases and not just your specific build system.

    Thread Starter Aarón

    (@aaronfc)

    Hi @timwhitlock thanks for your response!
    I think that, at the moment, we can wait for the next release.

    Is there any ticket we can follow so that we are aware when the change has been implemented?

    Plugin Author Tim W

    (@timwhitlock)

    You can follow this ticket. I’ll post back once there’s something in the trunk.

    Plugin Author Tim W

    (@timwhitlock)

    I’ve just added a new filter to trunk (loco_compile_script_reference).

    I’ll document it before it goes live, but briefly it works like this:

    /**
     * @param bool whether the script file exists on disk
     * @param string relative path to script file, either .js or .min.js
     * @param string script text domain for theme or plugin
     * @return bool whether to compile a JSON file for this script
     */
    function compile_script_reference_for_my_domain( $bool $relative $domain ){
        if( 'my-domain' === $domain  ){
            return true;
        }
        return $bool;
    }
    
    add_filter('loco_compile_script_reference','compile_script_reference_for_my_domain',999,3);

    Let me know what you think.

    Thread Starter Aarón

    (@aaronfc)

    Hi @timwhitlock,
    that looks good!

    Thanks 🙂

    Thread Starter Aarón

    (@aaronfc)

    I have prepared a branch with our fix (using your new filter) and it works great.

    I think we can release our part already but it would be nice so that we can ping the clients complaining about this as soon as all the parts are released.

    Do you have any ETA for the next release?

    Plugin Author Tim W

    (@timwhitlock)

    I want to release ASAP, but I have another issue to fix first. Hopefully today.

    Plugin Author Tim W

    (@timwhitlock)

    This is now live in 2.6.0

    Thread Starter Aarón

    (@aaronfc)

    Wow, so fast! Thanks @timwhitlock!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Request: Disable file existence check to generate JSON files.’ is closed to new replies.