How to set translations in javascripts for my plugin?

The WordPress way to do this is the wp_localize_script() function. When you enqueue a script, also add a call to wp_localize_script(): wp_register_script( ‘my-script’, ‘path/to/script.js’ ); wp_localize_script( ‘my-script’, ‘myScript’, array( ‘msg_must_match’ => __( ‘Message must match’, ‘my-plugin-domain’ ), ) ); This creates a global JavaScript object called myScript that will contain the keys and values passed … Read more

How to translate functions like get_the_date()?

Why not do it in plain PHP? For example, you can write a function like: function get_the_german_date($date=””, $post = null) { $d = get_the_date($date, $post); if ($d) { $d = new DateTime($d); return $d->format(‘d.m.Y’); } else return false; } Similary, if you want to follow the WordPress standards: function the_german_date($date=””, $post = null) { $d … Read more

Removing translation textdomain

I’ve actually been in the exact situation you’re in before, all you need to do is drop the __()s and the _e()s and replace them with their first parameter, you can pretty easily do this by regex if there are a lot, and it’s quick to do by hand if there aren’t…I’m not sure what … Read more

Translated my theme (translation not showing up)

You have incomplete code. You register your Theme’s textdomain, but don’t actually tell WordPress to load your translation files. To this: load_theme_textdomain(‘INTERluminaires’, get_template_directory() . ‘/languages’); Add this: $locale = get_locale(); $locale_file = get_template_directory() . “/languages/$locale.php”; if ( is_readable( $locale_file ) ) { require_once( $locale_file ); } Or, altogether (and wrapped properly in a callback): <?php … Read more

where to set the PO file for a plugin?

First of all, the plugin should support translation. If it is so, the directory where to put po/mo file is defined by plugin, usually they are in a directory /langs or /languages in plugin directory. That directory is (should be) defined by plugin using load_plugin_textdomain The plugin you are using has a subfolder cimy-user-extra-fields/langs where … Read more

Proper use of internationalization

The two are exactly the same but I would go for the first one: Easier to read No interpolation, keep interpolation for variables And, including the tags inside the format is making things more complicated, I can think of designers being tempted to use more tags if they see you are using them.

Fetch ID’s associated with a custom post type when translated with WPML?

NOTE: I’m not giving a full answer to your question but trying to give some snippets that may help in WPML-based project. I’ve used this function: function get_the_translated_ID($id){ if (!class_exists(‘sitepress’) return $id; global $sitepress; $type=get_post_type($id); return icl_object_id( $id, $type, false, $sitepress->get_default_language()); } This allows, for example, to search for custom_meta values of the original post … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)