• Hi there,

    I want to create a pot file for translate a few additional strings in my child theme . The parent theme is sydney.
    In the child code, I added a the lines :
    – Text Domain: sydney-child im the style.css
    – function my_child_theme_setup() {
    load_child_theme_textdomain( ‘sydney-child’, get_stylesheet_directory() . ‘/languages’ );
    }
    add_action( ‘after_setup_theme’, ‘my_child_theme_setup’ );
    in functions.php

    In the php files of my child theme I could have lines like
    echo __(“Comments are closed.”,”sydney”); // <- parent’s text domain
    echo __(“Legal terms”,”sydney-child”); // <- child’s text domain

    In my pot file, I just want to find the additional strings of my child theme.

    I’ve tried to generate the pot using :
    the poedit tool
    the makepot tool

    In both case the result is the same : I have the strings of the parent and child theme in the generated pot file.

    Is there a way to avoid this ?

    PS : the loco translate plungin seems to fix this issue. But I don’t want to use a plugin to translate 3 or 4 additional strings.

    Thanks for your help.

    Catherine.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    I’ve been waiting to see if someone knowledgeable with gettext and its relations would reply. For the sake of you getting some kind of answer, I’ll bite. Yes, apparently those .pot tools work by file and not by text domain. They simply identify strings in all translation functions regardless of text domain. That’s unfortunate, your use case seems to not be unusual.

    I know this is a lame suggestion, but if all you need is a .pot file for 3 or 4 strings, it’s probably easiest to simply manually paste together your own file from the overall poedit output. Use the same header, then paste in your specific entries for each of your strings.

    Maybe I’m missing something, but writing such a tool doesn’t sound that complicated. Any scripting language that supports regexp should work. Or obtain the poedit source and modify and recompile. Maybe someone has already done so. Have you tried searching through code repositories like github? Before such a coding endeavor, compile a .mo file for your strings and ensure your child theme works with two language files. I don’t see why it wouldn’t, but maybe there’s a reason poedit doesn’t work through text domains.

    I’m running on without knowing much. If anyone knows better, speak up!

    Dion

    (@diondesigns)

    Are you supporting multiple languages in the child theme? If not, then just directly use the translations in your custom child theme files…there’s no need to mess with the gettext stuff.

    Thread Starter catheg

    (@catheg)

    Thanks for your answers.

    My site is multilingual French and English.

    I was thinking maybe that the makepot tool could differentiate the text domain since it’s supposed to be a specific wordpress tool.

    Anyway, as you suggested, I generated a pot file with poedit for my child theme, then manually deleted the entries for the parent strings, compiled, created the po file, put all the files in the languages directory of my child theme.

    It works fine.

    Not very a very clean method, but for now it’s enough.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to generate a child theme pot file’ is closed to new replies.