Upgrade to Pro — share decks privately, control downloads, hide ads and more …

i18n - String translate and Poedit

i18n - String translate and Poedit

Funzioni base di WordPress per rendere il proprio progetto tema o plugin localizzabile

WordPress Meetup Catania

November 13, 2016
Tweet

More Decks by WordPress Meetup Catania

Other Decks in Education

Transcript

  1. WordPress Meetup Catania - Titolo Speech, Nome Cognome i18n -

    l10n Internationalization and localization
  2. WordPress Meetup Catania - Titolo Speech, Nome Cognome Internationalization Internationalization

    is the process of developing your plugin so it can easily be translated into other languages.
  3. WordPress Meetup Catania - Titolo Speech, Nome Cognome Localization Localization

    describes the subsequent process of translating an internationalized plugin.
  4. WordPress Meetup Catania - Titolo Speech, Nome Cognome Gettext WordPress

    uses the gettext libraries and tools for i18n. Gettext is an old and respectable piece of software, widely used in the open-source world. *gettext is currently being maintained by Daiki Ueno.
  5. WordPress Meetup Catania - Titolo Speech, Nome Cognome .PO Files

    A .po file is made up of many entries, each entry holding the relation between an original untranslated string and its corresponding translation.
  6. WordPress Meetup Catania - Titolo Speech, Nome Cognome .PO (

    Portable Object ) white-space # translator-comments #. extracted-comments #: reference… #, flag… #| msgid previous-untranslated-string msgid untranslated-string msgstr translated-string #: lib/error.c:116 msgid "Unknown system error" msgstr "Error desconegut del sistema"
  7. WordPress Meetup Catania - Titolo Speech, Nome Cognome .POT (

    Portable Object Template ) This is the file that you get when you extract texts from the application. Normally, you send this file to your translators.
  8. WordPress Meetup Catania - Titolo Speech, Nome Cognome .MO (

    Machine Object ) The .mo file includes the exact same contents as .po file. .mo files are compiled and are easy for computers to read.
  9. WordPress Meetup Catania - Titolo Speech, Nome Cognome Translation Functions

    __ _e esc_attr__ esc_attr_e esc_html__ esc_html_e __( ‘Text to translate’, ‘textdomain’ ) _e( ‘Text to translate echoed’, ‘textdomain’ ) esc_attr__( ‘Escaped text’, ‘textdomain’ ) esc_attr_e( ‘Escaped echoed text’, ‘textdomain’ ) esc_html__( ‘Escaped html chars’, ‘textdomain’ ) esc_html_e( ‘The echoed version’, ‘textdomain’ )
  10. WordPress Meetup Catania - Titolo Speech, Nome Cognome Context Translation

    Functions _x:1,2c _ex:1,2c esc_attr_x:1,2c esc_html_x:1,2c _x( ‘Text to translate’, ‘context’, ‘textdomain’ ) _ex( ‘Text, ‘context’, ‘textdomain’ ) esc_attr_x( ‘Text’, ‘context’, ‘textdomain’ ) esc_html_x( ‘Text’, ‘context’, ‘textdomain’ ) 1,2c says that the first string is the string to translate, the second string is the comment, context.
  11. WordPress Meetup Catania - Titolo Speech, Nome Cognome Plural Translation

    Functions _n:1,2 _nx:4c,1,2 _n_noop:1,2 _n_noop:4c,1,2 _n( ‘singular’, ‘plural’, ‘number’, ‘textdomain’ ) _nx( ‘singular’, ‘plural’, ‘number’, ‘context’, ‘textdomain’ ) _n_noop( ‘singular’, ‘plural’, ‘textdomain’ ) _nx_noop( ‘singular’, ‘plural’, ‘context’, ‘textdomain’ ) 4c,1,2 = says that the first and second arguments of the function are the plural forms, and the fourth is the disambiguation text.
  12. WordPress Meetup Catania - Titolo Speech, Nome Cognome Plural Translation

    Functions translate_nooped_plural _translate_nooped_plural( $nooped_plural, $count, $domain ) Translate the result of _n_noop() or _nx_noop()
  13. WordPress Meetup Catania - Titolo Speech, Nome Cognome POEDIT Write

    translations for any software or web site that uses Gettext for localization.
  14. WordPress Meetup Catania - Titolo Speech, Nome Cognome POEDIT 1.

    Create new translation. 2. Select the language. 3. Set the catalog properties.
  15. WordPress Meetup Catania - Titolo Speech, Nome Cognome POEDIT 4.

    Set the file base path. 5. Add the paths where the files are stored. 6. Exclude paths.
  16. WordPress Meetup Catania - Titolo Speech, Nome Cognome POEDIT 7.

    Add the functions used by your application.
  17. WordPress Meetup Catania - Titolo Speech, Nome Cognome Links I18n

    / l10n https://goo.gl/d8QKfY Plural Forms https://goo.gl/1vbNMv About noop https://goo.gl/PnNQpT Poedit translation secrets https://goo.gl/KhpPa8