wordpresspluginstranslation

How do I translate partially translated texts on my Wordpress website


I am new to wordpress and I am encountering a problem with translation from English to Danish. My theme and plugins are in Danish, but on my post page, where it is possible to navigate to my posts, it still says in English ‘Read more’? enter image description here

When I look in the code, I see that I have a plugin called Spicebox, but I don't see how it gets the text value? enter image description here

I've tried using Loco Translate and tried searching for Read more, but it doesn't find anything?enter image description here Does anyone know how I can get it translated?

UPDATE: I found out after some investigation of the PHP files in the file manager that Read more is a hard coded value which is located in a helper function for my parent theme Spice software.

helper-function.php in Spice-Software enter image description here


Solution

  • Check that the theme or plugin has localized the "Read More" text - it may have been overlooked by translators.

    Themes and plugins should have a folder called "languages" that contain the language files used in localization.

    For plugins this should be <root>\wp-content\plugins\<pluginname> For themes: <root>\wp-content\themes\<themename>

    Using Spicepress as our example, the language folder would be public_html\wp-content\themes\spicepress\languages on my website.

    In this folder is a Portable Object Template file (pot).

    Spicepress languages\spicepress.pot

    The file contains all the text referenced by the theme, including where in code that reference is made.

    "Read More" text is defined in the pot file:

    #: content-page.php:24 content-single.php:34 content.php:41 
    #: content.php:45  
    #: content.php:53 functions/template-tags.php:53  
    #: functions/template-tags.php:263 index-news.php:60  
    #: template/template-page-full-width.php:29  
    msgid "Read More"
    msgstr ""
    

    Placing the translated text "Læs mere" (I used Google Translate) between the empty quotation marks after msgstr and compiling to .mo / .po will generate the needed language files. WordPress localization documentation has instructions for compiling.

    The compiled files will only have the text which has been translated, so the files sizes will be smaller than the main .pot file

    A simple way to do this is use Poedit. The application provides an interface for handling the translations and will generate the po/mo files.

    Load the spicepress.pot file in Poedit, make your change and save.

    Rename the .mo file using the format of _.mo

    For my testing I did da_DK.mo, for Danish Denmark. Once I renamed and uploaded to the Spicepress theme language folder the translation took effect. I did not upload the .po file.

    I also set the language to "Dansk" in WordPress Settings -> General

    Additional Info: