How to translate (or edit) validation messages or "labels" in wordpress plugins?

0

As an example, I installed a plugin to add an attachment upload field in Wordpress's comments form- link How can I change the texts in "attachmentRules" and "choose file" using functions.php in my child-theme?

Comment form prtSc with firebug open: link

<!-- HTML começa aqui-->

<p class="comment-form-url comment-form-attachment"><label for="attachment">Adicione um anexo<small class="attachmentRules">&nbsp;&nbsp;(Allowed file types: <strong>jpg, gif, png, pdf, doc, docx</strong>, maximum file size: <strong>2MB.</strong></small></label></p>
<p class="comment-form-url comment-form-attachment"><input id="attachment" name="attachment" type="file"></p>

<!-- HTML termina aqui -->
    
asked by anonymous 03.02.2015 / 18:39

1 answer

0

Every good Wordpress plugin or theme has translation files.

This plugin you are using is no different. Inside the plugin folder there is a folder called 'languages' with two files 'comment-attachment-de_DE.po' and 'comment-attachment-de_DE.mo'

The name of these files is divided into 3 parts:

  • The name of the 'comment-attachment' plugin. So Wordpress will know which plugin that file refers to.

  • The code of the language and country to which it refers. The first two lowercase letters refer to the language and the two capital letters to country .

  • The extension of the .po or .mo file. The .po file is what we will edit and the .mo is the one used by Wordpress to load the translation.

  • Although you can open these files in a text editor, to edit the .po files safely you will need a program. I've indicated or Poedit .

    Now just open the .po file with Poedit, change the translations from German to Portuguese and save the file as 'comment-attachment-pt_PT.po'. Poedit will automatically generate a file with the .mo extension in the same directory.

    You should then upload the two 'comment-attachment-pt_PT.po' and 'comment-attachment-en.mo' files to the wp-content / languages / plugins folder. And ready! The plugin is translated.

    It is important that the language of your Wordpress is pt_PT too. To do this, just change wp_config.php and add (or change) the line define ('WPLANG', 'pt_PT'); .

    After doing the translation, contact the author of the plugin to add it to the package.

        
    08.02.2015 / 01:07