WORDPRESS MULTILENGUAJE WPML y sus alternativas
CONTENIDO WordPress y el multilenguaje. Ficheros PO. Que es WPML? WPML y los plugins. WPML + WooCommerce. WPML Avanzado Otros gestores multilenguaje.
WORDPRESS Y EL MULTILENGUAJE QUE ES NECESARIO TRADUCIR? Temas. Entradas y páginas. Plugins. Categorías y etiquetas. Links. Menús. Librería multimedia. Campos personalizados.
FICHEROS PO POR QUE ES NECESARIO USARLOS Y COMO Traduce todo lo que no es estrictamente el contenido de WordPress. Es muy sencillo de usar. Se pueden usar las traducciones de otros, por ejemplo de los temas o plugins. Son fáciles de usar por los traductores. En principio no necesitamos ningún plugin adicional. WordPress los actualiza y descarga de forma automatica.
COMO FUNCIONA UN PO Un fichero PO es un fichero de texto que posteriormente es compilado a formato MO, el contenido de un fichero PO es el siguiente: msgid "" msgstr "" "Project-Id-Version: Flexible 1.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2013-02-01 23:34+0300\n" "PO-Revision-Date: \n" "Last-Translator: Ann <anochka1985@gmail.com>\n" "Language-Team: Ann <anochka1985@gmail.com>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-KeywordsList: _e; ;esc_html ;esc_html_e;esc_attr ;esc_attr_e\n" "X-Poedit-Basepath:.\n" "Plural-Forms: nplurals=2; plural=(n!= 1);\n" "Language: es_es\n" "X-Generator: Poedit 1.7.3\n" "X-Poedit-SearchPath-0:.\n" "X-Poedit-SearchPath-1:..\n" #:../comments.php:4 msgid "Please do not load this page directly. Thanks!" msgstr Por favor, usa el po y te ahorraras muchos dolores de cabeza, Yeah!
DE VERDAD TENGO QUE USAR FICHEROS DE TEXTO PARA GESTIONAR FICHEROS PO? NO
USAREMOS POEDIT http://poedit.net/
Contenido del PO Texto original Traducción
Lista de códigos: http://wpcentral.io/internationalization
QUE ES WPML? Gestión integral de idiomas para WordPress. Permite traducir los contenidos. Permite duplicar contenidos para luego traducirlos. Gestión de los campos personalizados. La mayoría de los plugins mas importantes son compatibles. Tienen servicio de traducción en linea. Cambio del idioma del navegador automático. Gestión de duplicidad de archivos multimedia. Sincronización de menús. Importación y exportación de ficheros PO. Soporte de usuario bueno. Modelo basado en base de datos.
INSTALACIÓN Y CONFIGURACIÓN WPML Multilingual CMS WPML String Translation WPML Translation Management WPML Sticky Links WPML Translation Analytics WPML CMS Nav WPML Media WooCommerce Multilingual Beta https://wpml.org/es/account/downloads/
INSTALACIÓN Y CONFIGURACIÓN REGISTRO DE UN SITIO
PARÁMETROS MÁS UTILIZADOS
GESTIONANDO LOS CONTENIDOS, AJUSTANDO ALGUNAS COSAS PRIMERO
GESTIONANDO LOS CONTENIDOS
GESTIONANDO LOS CONTENIDOS
LOS MENUS
LOS MENUS
CATEGORIAS Y ETIQUETAS
CONTENIDO MULTIMEDIA
DUPLICADOR DE CONTENIDOS FACILITÉMONOS LA VIDA NO?
DUPLICAR DE CONTENIDOS FACILITÉMONOS LA VIDA NO?
GESTOR DE CADENAS
GESTOR DE CADENAS
GESTOR DE CADENAS
GESTOR DE CADENAS Autoregistro de cadenas function st($value='', $context='', $name=''){ if(empty($name)){ $name=substr(str_replace(' ', '_', $value), 0, 40); } icl_register_string($context, $name, $value ); return print_r(icl_t($context, $name, $value)); } function ste($value='', $context='', $name=''){ if(empty($name)){ $name=substr(str_replace(' ', '_', $value), 0, 40); } icl_register_string($context, $name, $value ); return icl_t($context, $name, $value); }
PLUGINS mi recomendación máxima: Buscar plugins y temas compatibles WPML: http://wpml.org/documentation/theme-compatibility/ http://wpml.org/documentation/plugins-compatibility/ Usar ficheros PO del plugin o tema.
PLUGINS
WOOCOMMERCE MULTILINGUAL
WOOCOMMERCE MULTILINGUAL
WOOCOMMERCE MULTILINGUAL
WOOCOMMERCE MULTILINGUAL http://wpml.org/documentation/related-projects/woocommerce-multilingual/
WPML AVANZADO Truco para WooCommerce CSV Import SELECT CONCAT(LEFT(wp_postmeta.meta_value,6), UCASE(wp_icl_translations.language_code)) as SKU FROM wp_postmeta JOIN wp_posts ON wp_posts.id=wp_postmeta.post_id JOIN wp_icl_translations ON wp_posts.id=wp_icl_translations.element_id WHERE wp_posts.post_type='product' AND wp_icl_translations.language_code IN ('es','en','fr') AND wp_postmeta.meta_key = '_sku' UPDATE wp_postmeta JOIN wp_posts ON wp_posts.id=wp_postmeta.post_id JOIN wp_icl_translations ON wp_posts.id=wp_icl_translations.element_id SET wp_postmeta.meta_value = CONCAT(LEFT(wp_postmeta.meta_value,6), UCASE(wp_icl_translations.language_code)) WHERE wp_posts.post_type='product' AND wp_icl_translations.language_code IN ('es','en','fr') AND wp_postmeta.meta_key = '_sku' UPDATE wp_postmeta JOIN wp_posts ON wp_posts.id=wp_postmeta.post_id JOIN wp_icl_translations ON wp_posts.id=wp_icl_translations.element_id SET wp_postmeta.meta_value = LEFT(wp_postmeta.meta_value,6) WHERE wp_posts.post_type='product' AND wp_postmeta.meta_key = '_sku' Revisar lenguaje del producto: Agregar lenguaje del producto: Quitar lenguaje del producto: https://wordpress.org/plugins/woocommerce-csvimport/
WPML Y ADVANCED CUSTOM FIELDS add_action( 'woocommerce_after_single_product_summary', "ACF_product_content", 10 ); function ACF_product_content(){ echo '<h2> ACF Content </h2>'; the_field('coste_promedio'); }
WPML Y ADVANCED CUSTOM FIELDS ACF Form Demo <?php acf_form_head();?> <?php get_header();?> <div id="primary" class="content-area"> <div id="content" class="site-content" role="main"> <?php /* The loop */?> <?php while ( have_posts() ) : the_post();?> <?php acf_form();?> <?php endwhile;?> </div><!-- #content --> </div><!-- #primary --> <?php get_sidebar();?> <?php get_footer();?> http://www.advancedcustomfields.com/resources/acf_form/
WPML Y ADVANCED CUSTOM FIELDS Cambiando el nombre del campo según valor de la tabla options: add_filter('acf/settings/default_language', 'my_acf_settings_default_language'); function my_acf_settings_default_language( $language ) { return 'en'; } add_filter('acf/settings/current_language', 'my_acf_settings_current_language'); function my_acf_settings_current_language( $language ) { return 'fr'; } http://www.advancedcustomfields.com/resources/multilingual-custom-fields/
WPML AVANZADO Ejemplo de uso de la API, creando un producto de WooCommerce en todos los idiomas global $woocommerce, $sitepress, $post; $my_post = array( 'post_title' => $_POST['producto'], 'post_content' => '', 'post_status' => 'publish', 'post_author' => 1, 'post_type' =>'product' ); $current_lang = $sitepress->get_current_language(); $list_idiomas = icl_get_languages('skip_missing=n&orderby=key&order=dir&link_empty_to=str'); $product_id = wp_insert_post( $my_post ); if ( $product_id ) { registra_producto($product_id); foreach($list_idiomas as $l) { if ($l['language_code']!= $current_lang) { $product_id = mwm_wpml_translate_post($product_id, 'product', $l['language_code']); } }; } if ( $product_id ) { registra_producto($product_id); } function registra_producto($product_id) { } // Resto de campos del producto
WPML AVANZADO Ejemplo de uso de la API, como crear un producto de WooCommerce en todos los idiomas function mwm_wpml_translate_post( $post_id, $post_type, $lang ){ }; // Include WPML API include_once( WP_PLUGIN_DIR. '/sitepress-multilingual-cms/inc/wpml-api.php' ); // Define title of translated post $post_translated_title = get_post( $post_id )->post_title; $post_translated_description = get_post( $post_id )->post_content; // Insert translated post $post_translated_id = wp_insert_post( array( 'post_title' => $post_translated_title, 'post_type' => $post_type, 'post_content' => $post_translated_description, 'post_status' => 'publish', 'post_author' => 1 )); // Get trid of original post $trid = wpml_get_content_trid( 'post_'. $post_type, $post_id ); // Get default language $default_lang = wpml_get_default_language(); // Associate original post and translated post global $wpdb; $wpdb->update( $wpdb->prefix.'icl_translations', array( 'trid' => $trid, 'language_code' => $lang, 'source_language_code' => $default_lang ), array( 'element_id' => $post_translated_id ) ); // Return translated post ID //print_r($post_translated_id); return $post_translated_id; http://wpml.org/documentation/support/wpml-coding-api/
WPML AVANZADO EL FICHERO WPML-CONFIG.XML Nos permite configurar desde un fichero el comportamiento de WPML Opciones y textos administrativos <admin-texts> <key name="my_plugins_options"> <key name="option_name_1" /> <key name="option_name_2" /> <key name="options_group_1"> <key name="sub_option_name_11" /> <key name="sub_option_name_12" /> </key> <key name="options_group_2"> <key name="sub_option_name_21" /> <key name="sub_option_name_22" /> </key> </key> <key name="simple_string_option"/> </admin-texts> http://wpml.org/documentation/support/language-configuration-files/
WPML AVANZADO EL FICHERO WPML-CONFIG.XML Custom Fields <custom-fields> <custom-field action="copy">quantity</custom-field> <custom-field action="translate">custom-title</custom-field> <custom-field action="copy">weight</custom-field> <custom-field action="translate">custom-description</custom-field> <custom-field action="ignore">date-added</custom-field> </custom-fields> Custom Types <custom-types> <custom-type translate="1">book</custom-type> <custom-type translate="1">dvd</custom-type> </custom-types> Custom Taxonomies <taxonomies> <taxonomy translate="1">genre</taxonomy> <taxonomy translate="1">type</taxonomy> <taxonomy translate="0">publisher</taxonomy> </taxonomies> Selector de idiomas <language-switcher-settings> <key name="icl_lang_sel_config"> <key name="font-current-normal">#444444</key> <key name="font-current-hover">#000000</key> <key name="background-current-normal">#ffffff</key> <key name="background-current-hover">#eeeeee</key> <key name="font-other-normal">#444444</key> <key name="font-other-hover">#000000</key> <key name="background-other-normal">#ffffff</key> <key name="background-other-hover">#eeeeee</key> <key name="border">#cdcdcd</key> </key> <key name="icl_lang_sel_footer_config"> <key name="font-current-normal">#444444</key> <key name="font-current-hover">#000000</key> <key name="background-current-normal">#ffffff</key> <key name="background-current-hover">#eeeeee</key> <key name="font-other-normal">#444444</key> <key name="font-other-hover">#000000</key> <key name="background-other-normal">#ffffff</key> <key name="background-other-hover">#eeeeee</key> <key name="border">#cdcdcd</key> </key> <key name="icl_language_switcher_sidebar">0</key> <key name="icl_widget_title_show">0</key> <key name="icl_lang_sel_type">dropdown</key> <key name="icl_lso_link_empty">0</key> <key name="icl_lso_flags">0</key> <key name="icl_lso_native_lang">1</key> <key name="icl_lso_display_lang">1</key> <key name="icl_lang_sel_footer">0</key> <key name="icl_post_availability">0</key> <key name="icl_post_availability_position">below</key> <key name="icl_post_availability_text">this post is also available in: %s</key> </language-switcher-settings> http://wpml.org/documentation/support/language-configuration-files/
WPML AVANZADO Opciones de recuperación y soporte
WPML AVANZADO Opciones de recuperación y soporte
WPML AVANZADO OTROS TEMAS RELACIONADOS Importaciones: http://www.wpallimport.com/ Idioma EN no es el default: http://wpml.org/documentation/support/ translating-woocommerce-sites-default-language-english/
OTROS PLUGINS MULTILENGUAJE QTranslate. Loco Translate
QTRANSLATE http://www.qianqin.de/qtranslate/ Formato interno: ( <!--:ca-->titol<!--:--><!--:es-->título<!--:--><!--:en-->title<!--:-->")
QTRANSLATE Instalación y notas Basicamente son dos plugins a instalar: qtranslate: https://wordpress.org/plugins/qtranslate/ qtranslate Slug: https://wordpress.org/plugins/qtranslate-slug/ Nota: Si tenéis problemas con el plugin por la versión podeis probar esto: Modificar el fichero: plugins/qtranslate.php define('qt_supported_wp_version', 4.1'); y ponéis la versión actual que tengáis. Alternativa basada en QTranslate: https://wordpress.org/plugins/mqtranslate/
LOCO TRANSLATE https://wordpress.org/plugins/loco-translate/ Permite editar directamente los archivos PO de los temas y plugins. No es necesario el Poedit.
RUEGOS Y PREGUNTAS Por que seguro que algo me he dejado!