themeum / kirki

Extending the customizer
https://kirki.org
MIT License
1.26k stars 328 forks source link

Translation issue #1023

Closed voidlz closed 8 years ago

voidlz commented 8 years ago

Issue description:

HI I can't translate text in customizer (via Poedit). Customizer options created without kirki works well.

Version used:

dev 2.3.4

aristath commented 8 years ago

How exactly are you adding that text? Can you please post your code here? Or are you talking about the translation strings from the Kirki plugin itself?

voidlz commented 8 years ago

For example:

Kirki::add_field( 'my_config', array(
    'type'     => 'text',
    'settings' => 'my_setting',
    'label'    => __( 'Text Control', 'my_textdomain' ),
    'section'  => 'my_section',
    'default'  => esc_attr__( 'This is a defualt value', 'my_textdomain' ),
    'priority' => 10,
) );

I'm trying translate Text Control and This is a defualt value

aristath commented 8 years ago

This has nothing to do with Kirki... Have you defined your theme's textdomain as my_textdomain? Are you sure that's properly defined as per the WordPress instructions? do your other strings use the same textdomain? Are you properly including the file? Have you regenerated the .po/.mo/.pot files for your theme?

Closing this one as it's not related to Kirki.

voidlz commented 8 years ago

Live example: twentysixteen-child.zip Just switch language to russian.

aristath commented 8 years ago

reopening so I don't forget to take a look tomorrow.

fredserva commented 8 years ago

I've experienced the same issue. So, I decided to dig into the plugin. I haven't found anything wrong with the plugin but I found the solution. At the beginning of my configuration file, I just put this: load_theme_textdomain( 'my_textdomain', get_template_directory().'/languages' ); I already declared load_theme_textdomain in my functions.php but apparently that was not enough :) Now, everything is fine.

I think you may can close this issue. BTW, Aristeides, your plugin is just great!

aristath commented 8 years ago

@fredserva thanks!

Closing this one. BTW, if you use Kirki as a plugin instead of embedding it in a theme this is not an issue at all, and translations are updated automatically from wordpress.org 👍

xtra-strona commented 8 years ago

I'm sorry but my English is poor ... I had the same problem and should be removed IN THIS DEFAULT FUNCTION BAD ::: if ( ! function_exists( 'your_setup' ) ) : function your_setup() { load_theme_textdomain( 'my_textdomain', get_template_directory().'/languages' );
} endif; // your_setup add_action( 'after_setup_theme', 'your_setup' );
To This :
without if ( ! function_exists( 'your_setup' ) ) : { REMOWE ALL } GOOD :::
load_theme_textdomain( 'my_textdomain', get_template_directory().'/languages' );

Slobork commented 7 years ago

I've had to do the same as @fredserva suggested.

The issue was occuring in both cases (with Kirki embeded in a theme or Kirki activated as a plugin).

tjuris commented 7 years ago

Had the same issue. I added the conditional is_customize_preview around the second load_textdomain call, like this:

// separate call for kirki
if ( is_customize_preview() ) {
    load_theme_textdomain( 'my-custom-theme-textdomain', get_template_directory() . '/lang' );
}
rmego commented 7 years ago

Hey @aristath, can you please reopen this issue?

The solution from @fredserva works (thanks) but is not optimal.

I saw that a new I10n implementation was added in the latest versions, but it's not working for some reason.

If you want to take a look, I have created a vanila _s test theme with the latest version (3.0.11) embedded: test_theme.zip

aristath commented 7 years ago

There was a bug with translations, fixed in https://github.com/aristath/kirki/commit/a3f86d64b4f28e86d13231ab04c50e71a6d86c1f and will be included in v3.0.12 which will be released shortly.