Textdomain for translation not loaded in frontend dashboard

WCMp PDF Invoice

Textdomain for translation not loaded in frontend dashboard Resolved

Viewing 9 reply threads
  • Author
    Posts
    • #66242

      Hi and thank you for your plugins!

      I am trying to translate the pdf-invoices plugin as well as the frontend-report plugin but unfortunately am unable to do so. I am using poedit for translation and want to load all translations from a custom folder via the

      load_textdomain_mofile
      copy

      filter. This works out well except for the 2 plugin mentioned above. When debugging I noticed that the textdomain for these plugins never gets loaded and added to the I110n global for the frontend dashboard. Can you please confirm this?

      Christian

    • #66299

      @Christian, we have tested the text domain with Loco plugin (). The translation is working fine with loco, all you have to do is follow this document: https://wc-marketplace.com/knowledgebase/wcmp-translation-guide/

      Now, as we haven’t worked with poedit, can you please check whether they have any settings, that reloads/syncs all the strings.

    • #66322

      I’d rather not use a plugin for this. I have found and translated all strings and generated an .mo file. I have placed this file inside wp-content/languages/custom-folder/
      At this point I want to let WordPress know where this file resides with the

      load_textdomain_mofile
      copy

      filter. See code below for a better understanding:

      function my_custom_pdfinvoicestranslation( $mofile, $domain ) {
      
      	if ( 'wcmp-pdf_invoices' === $domain ) {
      
      		$mofile = WP_LANG_DIR . '/custom-folder/wcmp-pdf_invoices-' . get_locale() . '.mo';
      
      	}
      
      	return $mofile;
      
      }
      copy

      This works well for all plugins but for the pdf-invoices and frontend report plugins the $domain variable (textdomain) is never available in the frontend manager. I suspect that that the textdomains for these plugins are not loaded/registered properly.

      The domain is available for the main wcmp plugin itself. I took a quick look and for this plugin the textdomain is loaded on WP init hook. For both the pdf-invoices and frontend-report pugins that don’t seem to work the textdomain is loaded within the class __construct and not via a hook. Could this be the problem?

    • #66335

      @Christian van Deursen, our team will look into this.

      I will keep you posted.

    • #66721

      @christian, our team has doubled check this.

      As you can see in this video, we didn’t face any issue with poedit : https://drive.google.com/file/d/1y_kuHqDmPz2_nMigSklHkZ0JqCvr4pb3/view

      Can you please check the procedure again.

    • #66754

      Hello Moumita,

      Thank you for looking into this and posting the video.
      Things do work fine when you try to add translations inside the standard wordpress folders like for example the ‘wp-content/plugins/wcmp-pdf_invoices/languages/wcmp-pdf_invoices-nl_NL.mo’ and ‘wp-content/languages/plugins/wcmp-pdf_invoices-nl_NL.mo’. However it’s not possible to use wordpress hooks like the

      load_textdomain_mofile
      copy

      filter because the textdomain is not properly registered with wordpress and thus not available as a variable. If the load_plugin_textdomain function is executed on the ‘init’ hook other plugins and themes can make use of it. Also see https://developer.wordpress.org/reference/functions/load_plugin_textdomain/#user-contributed-notes for more information.

      To reproduce this issue for the pdf-invoices plugin and frontend-reports plugins:

      1. Create a folder

      my-custom-folder
      copy

      like: wp-content/languages/my-custom-folder/
      2. Put a translation file (.mo file) inside this folder
      3. Let WordPress now about the translation file with the

      load_textdomain_mofile
      copy

      filter (see my previous comment)

      Thanks!

    • #66865

      @Christian van Deursen, first can you please explain how you are loading the translation from the custom folder using load_textdomain_mofile. Small video capture will be very much helpful.

      Just to help you out further, we checked the documentation. As we can see, it is recommended to create “plugin” folder for plugin translation and “theme” folder for theme translation. You can check this document for further reference –
      https://docs.themeisle.com/article/893-translating-themes-using-poedit
      We also followed the same flow, and all our plugins are translated properly.

      Can you please follow this also for your site.

      However, if you still want to proceed with this load_textdomain_mofile, then please let us know how you are loading the translation.

    • #66925

      Hello Moumita,

      Nevermind, I will manage. I just wanted to bring this issue to your attention.

      Thank you.

    • #66940

      @christian, our will check this, however, we are not able to detect any issue poedit.

      That is why we have asked you to share the flow on how we can recreate the issue.

    • #75631
      susmita
      Moderator

      Hi @christian,

      I presume that your issue is resolved, since, we haven’t heard back from you.

      We are marking this thread as resolved.

      Kindly open a new thread if you face any further query.

Viewing 9 reply threads

The topic ‘Textdomain for translation not loaded in frontend dashboard’ is closed to new replies.

WCMp bundle is available at a slashed price

Grab It Now