• Hi,
    I’d like to translate hard coded text in functions.php file

    This is the code in functions.php:
    https://gist.github.com/anonymous/115f6baab37b0db5dddf

    I have changed the following code line:
    <div class="box-tipo"><div class="box-campo">Disegni: </div><div class="box-risultato"><ul class="box-voci">

    with this:
    <div class="box-tipo"><div class="box-campo"><?php echo _e( 'Disegni','customizr-child'); ?>:</div><div class="box-risultato"><ul class="box-voci">

    then in the .po english file, I added the following code line:

    #: customizr-child/functions.php:769
    msgid "Disegni"
    msgstr "Drawings"

    Where did I go wrong?

Viewing 6 replies - 1 through 6 (of 6 total)
  • echo _e( 'Disegni','customizr-child'); is redundant : _e( is enough or use echo __(..

    Have you compile your .po file in a .mo file ?

    Thread Starter oltrecomics

    (@oltrecomics)

    Hi Michel, thanks for your help.
    So, I’ve modified .po file in the parent template, while functions.php is present in the child theme.

    I honestly do not know how to create and to compile a .po file

    Given that I understand very little of programming code, I’d like to know which codes I have to add, in what files and where.

    Sorry for my bad English, I know little about this language.

    Thread Starter oltrecomics

    (@oltrecomics)

    If there anyone can give me a hand?

    Hi,

    I am not technical but a suggestion:
    Have you tried poedit for this purpose?

    Good luck!

    Thread Starter oltrecomics

    (@oltrecomics)

    Hi wph4, thanks for your help, but…
    I would like to know:
    1) if I have to create a new file .po in child theme and what is the code we I should put.
    2) which path I should put, if ilfile functiosn.php is located in child theme:

    #: customizr-child/functions.php:769 <---????which path
    msgid "Disegni"
    msgstr "Drawings"

    3) if I can add code line on .po file in parent theme instead child theme and which path I should put

    Hi oltrecomics.

    WordPress does not care about .po files, you must generate a .mo file 🙂

    Poedit (https://poedit.net/)is the easiest way to do it, will allow you edit the .po file and generate a .mo file https://developer.wordpress.org/themes/functionality/localization/

    Also notice that your strings must be in english, if your theme is using italian then it is doing it wrongly.

    The correct is to develop in english and then create the italian translation.

    https://codex.wordpress.org/I18n_for_WordPress_Developers

    Ciao,
    Gabriel

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Multilingual text in functions.php’ is closed to new replies.