• Resolved sir3453715

    (@sir3453715)


    I would like to create the translate file in my custom plugin,

    but when I create the po file in author path, it’s not working,

    if I change the file path to System or Custom ptah, than the translate is working,

    why will this happen? and hope someone can help me, I want the translate file in author path than when I install the plugin to my other site can have the translate.

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

    (@timwhitlock)

    This may not be related to Loco Translate. Your plugin and WordPress together load author-provided translations.

    Are you using load_plugin_textdomain with the correct path to your translations?

    Thread Starter sir3453715

    (@sir3453715)

    Thank you I found the problem!

    But I have other question for javascript translate,

    I’m not sure is my code problem or what, I cant translate the string in js and I didnt see the json file

    shloud I create by myself? or it will be auto created when I use “Loco Translate” to trans the string?

    thank you for your help again

    
    load_plugin_textdomain( 'custom',false, dirname(plugin_basename(__FILE__)) . '/languages/' );
    wp_register_script("custom-js", MTT_URL.'assets/js/custom.js', ['jquery','wp-i18n'], false, true);
    wp_enqueue_script('custom-js');
    wp_set_script_translations( 'custom-js', 'custom',dirname(plugin_basename(__FILE__)) . '/languages/' );
    
    Plugin Author Tim W

    (@timwhitlock)

    Loco Translate will generate the JSON file when it generates the MO file (i.e. when you save the PO file). BUT the JavaScript file reference must have been correctly extracted into the POT file from which your PO file is synced.

    JavaScript string extraction using Loco Translate must be enabled in settings. Enter “js” into the field titled “Scan JavaScript files with extensions”.

    See https://localise.biz/wordpress/plugin/manual/json

    Thread Starter sir3453715

    (@sir3453715)

    Thanks for your help! I can translate the string in js now!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Translate not working when po in Author path’ is closed to new replies.