• Resolved ankomm

    (@ankomm)


    Hi,

    I’ve the same problem as him here, your plugin allow translating only templates name.

    I read your ‘PLEASE READ BEFORE POSTING’ and done all of the “tutos” …

    In my templates I use <?php echo __('Actualites', 'pulsdesign'); ?> or <?php _e('Actualites', 'pulsdesign'); ?>

    Here is my xml :

    <?xml version="1.0" encoding="utf-8"?>
    <bundle name="pulsdesign">
      <domain name="pulsdesign">
        <project name="PulsDesign" slug="pulsdesign">
          <source>
            <directory>.</directory>
          </source>
          <target>
            <directory>languages</directory>
          </target>
          <template>
            <file>languages/pulsdesign.pot</file>
          </template>
        </project>
      </domain>
    </bundle>

    I hope it will works, your plugin is a bless !

    Have a nice day,

    Thanks,

    Ankomm

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Tim W

    (@timwhitlock)

    I don’t see anything wrong with your code.

    Please provide more detail. What are you doing to extract these strings into your pulsdesign.pot file?

    Thread Starter ankomm

    (@ankomm)

    What do you mean by ‘extract these strings’ ?

    DOn’t know is it will be usefull but here’s my style.php header :

    /*
    Theme Name: PulsDesign
    Theme URI: 
    Description: Child 01 theme for the Twenty Seventeen theme
    Author: Alix Hemery
    Text Domain: pulsdesign
    Author URI: 
    Template: twentyseventeen
    Version: 0.1.0
    */

    My load_theme_textdomain in functions.php :

    function my_theme_load_theme_textdomain() {
    load_theme_textdomain( 'pulsdesign', get_template_directory() . '/languages' );
    }
    
    add_action( 'after_setup_theme', 'my_theme_load_theme_textdomain' );
    • This reply was modified 7 years, 2 months ago by ankomm.
    • This reply was modified 7 years, 2 months ago by ankomm.
    • This reply was modified 7 years, 2 months ago by ankomm.
    Plugin Author Tim W

    (@timwhitlock)

    Your code is fine. Please describe the full process that led you to not seeing your strings in translation files.

    What do you mean by ‘extract these strings’ ?

    Meaning that you have to actually create your pulsdesign.pot. Have you done that?

    Loco Translate lets you skip that step and will create PO files directly from source code. Did you do that instead?

    You say you’ve read all the tutorials, but it sounds like you’re missing something out. See step 5. in How to translate a WordPress child theme.

    Perhaps I need to add more information about this step, but it’s not specific to my plugin. It’s how Gettetxt works. See Working with POT files.

    Thread Starter ankomm

    (@ankomm)

    Yep I created pulsdesign.pot, tried to add manually a translation :

    msgid "Mots-cles"
    msgstr "Keywords"

    Then added <?php echo __('Mots-cles', 'pulsdesign'); ?> in my PHP template, define('WPLANG', 'en_US'); in the header template, sync the plugin.
    The raw ‘Mots-cles’ appears in the string list under templates names with the traduction ‘Keywords’, saved and … nothing. My string still display ‘Mots-cles’.

    _____________________________________________________________________________________

    For the process : downloaded and installed the plugin in local and in the server (local for testing), configured my theme (helped by seing the Omega configuration), created the template, created a new translation in English (US) and that’s all. The list was filled with only templates names.

    Plugin Author Tim W

    (@timwhitlock)

    Almost everything you’ve done is wrong.

    1. WordPress’s source language is English (en_US) so your strings should be in English. So your code should look like:

    <?php echo __('Keywords', 'pulsdesign'); ?>

    2. WPLANG does nothing. Open your site settings and set your language to (I assume) French.

    3. POT files don’t have a language. They are templates, so msgstr fields should all be empty. You don’t need to add the strings manually either. Click “Sync” from your POT file and Loco Translate will extract your strings into it. Then click Save. If you are successful your POT will look like:

    msgid "Keywords"
    msgstr ""

    4. Now click “Add language” from your theme page and select your locale. Then use the editor to translate “Keywords” to “Mots-cles”.

    Thread Starter ankomm

    (@ankomm)

    I used the WPLANG and editing the POT file after I did the process (cf my last post) and saw it didn’t work. My language settings are on French since the creation of my theme.
    I used English words <?php echo __('Keywords', 'pulsdesign'); ?> and tried to translate in French but the problem is still there.

    Thank you for your patience !

    Plugin Author Tim W

    (@timwhitlock)

    The steps I’ve given will work if you follow them.

    If you still have a problem you need to describe exactly what you’ve done at every step.

    Thread Starter ankomm

    (@ankomm)

    Hi,

    Don’t undestand, my POT file and my previous translation were deleted (don’t know why and how), then I tried again the process exactly like the first time and … it works !

    Thanks for your help (and for the plugin) !

    Have a nice day,

    Ankomm

    Plugin Author Tim W

    (@timwhitlock)

    Ok good. Thanks for marking as resolved.

    Regarding deleted files: make sure automatic updates aren’t overwriting your files. If they’re inside your own theme they shouldn’t be, but be aware.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Can translate only templates name’ is closed to new replies.