38
WordPress - Internationaliz ation - Localization - Multilingual Do It Righ t

WordPress internationalization, localization, and multilingual

  • Upload
    mbigul

  • View
    65

  • Download
    2

Embed Size (px)

Citation preview

WordPress- Internationalizatio

n - Localization - Multilingual

Do It

Right

Me and CompanyBigul MalayiQA & Support at OnTheGoSystemsEmail: [email protected]: wpml.org

Twitter & Facebook: mbigul

Me and CompanyOnTheGoSystems

wp-types.com

wpml.org icanlocalize.com

Main Content

● Internationalization

● Localization

● Multilingual

What are They?Internationalization (i18n) is the process of developing your theme/plugin language, so it can easily be translated into other languages.

Localization (l10n) describes the subsequent process of translating an internationalized theme/plugin.

Multilingual means there are more than one language in sites.

Internationalization

Internationalization

Internationalization (1)Wrongecho 'WordPress is the best!';Right (use gettext functions)echo __( 'WordPress is the best!', 'my-text-domain' );

Wrong (don’t be clever!)__( 'Translate me.' , $my_text_domain );Right (no variable, constant… for text domains)__( 'Translate me.' , 'my-text-domain' );

Internationalization (2)Basic functions:● __(), _e()● _x(), _ex() - Disambiguation by context_x( 'Post', 'noun', 'my-text-domain' );_x( 'Post', 'verb', 'my-text-domain' );● _n(), _nx() - Plural/singular nounssprintf( _n( '%s star', '%s stars', $rating, 'text-domain' ), $rating );

● _n_noop(), _nx_noop(), translate_nooped_plural()

Internationalization (3) - JavaScriptfunction add_my_script() { // Register the script wp_register_script( 'some_handle', get_template_directory_uri() . '/custom.js' ); // Localize the script with new data $translation_array = array ( 'some_string' => __( 'Some string to translate', 'text-domain' ), 'a_value' => '10' ); wp_localize_script( 'some_handle', 'object_name', $translation_array ); // Enqueued script with localized data. wp_enqueue_script( 'some_handle' ); }add_action( 'wp_enqueue_scripts', 'add_my_script' );

Internationalization (4) - JavaScriptcustom.js<script> // alerts 'Some string to translate' alert( object_name.some_string);</script>

HTML:<script type='text/javascript'>/* <![CDATA[ */var object_name = {"some_string":"Some string to translate","a_value":"10"};/* ]]> */</script>

Internationalization (5) Date and number functions:- number_format_i18n()- date_i18n()

Escape functions:

esc_html__()esc_html_e()esc_html_x()

esc_attr__()esc_attr_e()esc_attr_x()

Internationalization (6) Load .mo files: function my_plugin_load_plugin_textdomain() { load_plugin_textdomain( 'text-domain', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );}add_action( 'plugins_loaded', 'my_plugin_load_plugin_textdomain' );

Localization (1)File Types

●POT (Portable Object Template)#: plugin-name.php:123msgid "Page Title"msgstr ""

●PO (Portable Object) ●MO (Machine Object)

Localization (2)Translate●Poedit●Plugins:

○Loco Translate○WPML String Translation

●Google Translator Toolkit●translate.wordpress.org

Localization (3)Feel localization!●Settings > General > Site language

●Put the correct folders○ wp-content/languages/plugins/text-domain-hi_IN.mo○ wp-content/plugins/my-plugin/languages/text-domain-

hi_IN.mo

Localization (4) Contribute: Everyone can help

●https://make.wordpress.org/polyglots/handbook/tools/glotpress-translate-wordpress-org/

●https://translate.wordpress.org/locale/hi/default/wp/dev

●https://translate.wordpress.org/projects/wp-plugins/woocommerce

Polygots

Polygots

Polygots team is mangaing WordPress Translations.

Current Statics

●164 locales●65 locales at 100%●3 locales have more than 95%●3 locales have more than 90%

Polygots

Polygots team is mangaing WordPress Translations.

Current Statics

●164 locales●65 locales at 100%●3 locales have more than 95%●3 locales have more than 90%

Polygots

Current Statics

●31 locales have more than 50% ●65 locales at 100%●55 locales have less than 50% ●87 locales have a language pack ●77 locales have no language pack ●7 locales don’t have a WP project

PolygotsCurrent Statics of Indian Language

●Hindi 100%●Urdu 100%●Marathi 100%●Guajarati 100% ●Bengali 94% ●Punjabi 68%●Telugu 71%●Tamil 63%●Malayalam 61%

GlotPress●Started as a stand alone project in 2008 by

Nikolay Bachiyski

●Uses BackPress as a framework

●In 2013 Marko Heijnen started managing

●In June 2015, Andrew Nacin began the work of transforming GlotPress into a plugin

●Dominik Schilling led the development on GitHub

●https://wordpress.org/plugins/glotpress/

Polygots

Polygots

Polygots

Polygots

Polygots

Polygots

Polygots

Polygots

Polygots

Multilingual

• Standalone WordPress environment

• WordPress Multisite

Multilingual (1)

Standalone WordPress environment • Polyglang (Free)

• qTranslate X (Free)

• WPML (Premium)

Multilingual (2)

WordPress Multisite • Multisite Language Switcher (Free)

• Multilingual Press (Free & Premium)

Discussion

Image credit: http://sweetclipart.com/diverse-people-raising-hands-968

Useful Links1. https://developer.wordpress.org/plugins/internationali

zation/localization2. https://developer.wordpress.org/plugin/internationaliz

ation/how-to-internationalize-your-plugin

3. https://codex.wordpress.org/I18n_for_WordPress_Developers

4. https://developer.wordpress.org/themes/functionality/internationalization/

Big Thanks!