Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
define( WPLANG, de_DE );                    $wp_local_package = de_DE;                     Session:                     Wo...
Themes & Plugins   nicht übersetzbar...   nur halbgar übersetzbar...Ursachen:                     Fehlendes Wissen        ...
Selbst Hand anlegen   WordPress bringt alles mit!   via PHP Gettext   Gettext Funktionen   Textdomain laden:      allgemei...
Einpflegen?  Nützlich bei allen öffentlichen Repo-Projekten    GitHub.com - simpel & elegant!    WordPress.org: Entwickler...
Implementieren                                             Für Text-Strings:Textdomain laden:                             ...
dein-plugin.php Kopfbereich, Metadaten:Plugins:                                /**                                 * Text ...
style.css Kopfbereich, Metadaten:Themes:                                /*                                   Text Domain: ...
style.css Kopfbereich, Metadaten:Child                                /*                                   Text Domain: de...
Themes:Sprachdatei-Ordner filtern/** Set filter for parent themes languages directory */$parent_theme_lang_dir = get_templ...
Plugins vs. Themes:Dateinamen der SprachdateienThemes:                                 Plugins:de_DE.mo /.po              ...
Themes vs. Child Themes get_template_directory() vs. get_stylesheet_directory() load_textdomain() vs. load_child_theme_tex...
Syntaxbeispiele IKorrekt:Templates:<?php_e( Germany consists of 16 federal states,textdomain );?>In Funktionen:echo __( Ge...
Immer:                                                     Single Quotes!Syntaxbeispiele II                             EI...
Syntaxbeispiele IIIErweitert: $string = sprintf( __( Germany consists of %d federal states, textdomain ), $number );$strin...
Syntaxbeispiele IVKontext:$string = _x( Frankfurt, German city at the riverMain, textdomain );$string = _x( Frankfurt, Ger...
Syntaxbeispiele VFormatierungen:$string = sprintf( __( <h1>I want %d Hefeweizen</h1>,textdomain ), $number );$string = <h1...
Syntaxbeispiele VISicherheit:      Benutzereingaben:                      Ausgaben von Text in                            ...
Syntaxbeispiele - Spezial INumerical No-op:$string = sprintf( _n( I have %d bike., You have %dbikes., $number, textdomain ...
Syntaxbeispiele - Spezial IIZahlen & Daten:number_format_i18n()date_i18n()David Decker · deckerweb.de · WP Camp 2012
Häufige Fehler:  Gar keine Übersetzbarkeit  Übersetzbarkeit JA, aber kein „load_textdomain“  Mischen von Single & Double Q...
Best Practices I  ALLES Übersetzbar machen!  Laden der Sprachdateien via Hook!  Textdomain als String in Single Quotes set...
Best Practices II  Pfadangaben checken!  load_textdomain() fordert absoluten Pfad  load_plugin/theme/child_theme_textdomai...
Werkzeuge:  define( WP_DEBUG, true ); (wp-config.php)  define( WPLANG, de_DE ); (wp-config.php)  Plugin: „Codestyling Loca...
Codestyling LocalizationDavid Decker · deckerweb.de · WP Camp 2012
Codestyling LocalizationDavid Decker · deckerweb.de · WP Camp 2012
GlotPress InstallationDavid Decker · deckerweb.de · WP Camp 2012
GlotPress InstallationDavid Decker · deckerweb.de · WP Camp 2012
GlotPress InstallationDavid Decker · deckerweb.de · WP Camp 2012
PoEdit Editor (poedit.net)David Decker · deckerweb.de · WP Camp 2012
Verwendete Quellen: http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/ http://ottopress.com/201...
Danke! Fragen jetzt! Folien unter:           deckerweb.de/wpcamp2012                         plus: slideshare.net/deckerwe...
/** Call for break and add next session */add_action( wpcamp_berlin_2012, wpc_next_session_planning )function wpc_next_ses...
Nächste SlideShare
Wird geladen in …5
×

WordPress Plugins und Themes übersetzbar machen - WP Camp 2012 Berlin

1.747 Aufrufe

Veröffentlicht am

WordPress Plugins und Themes übersetzbar machen - die Grundprinzipien, Grundfunktionen, hilfreiche Tipps, Tricks, Erfahrungen, häufige Fehler und Best Practices

Veröffentlicht in: Technologie
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • Gehören Sie zu den Ersten, denen das gefällt!

WordPress Plugins und Themes übersetzbar machen - WP Camp 2012 Berlin

  1. 1. define( WPLANG, de_DE ); $wp_local_package = de_DE; Session: WordPress Plugins und Themes übersetzbar machenDavid Decker · deckerweb.de · WP Camp 2012
  2. 2. Themes & Plugins nicht übersetzbar... nur halbgar übersetzbar...Ursachen: Fehlendes Wissen Keine Lust, beratungsresistent... Nur Fokus auf USA... Keine Tests durchgeführt Eigene Implementationen jenseits der StandardsDavid Decker · deckerweb.de · WP Camp 2012
  3. 3. Selbst Hand anlegen WordPress bringt alles mit! via PHP Gettext Gettext Funktionen Textdomain laden: allgemein Plugins Themes Child ThemesDavid Decker · deckerweb.de · WP Camp 2012
  4. 4. Einpflegen? Nützlich bei allen öffentlichen Repo-Projekten GitHub.com - simpel & elegant! WordPress.org: Entwickler kontaktieren Ziel: Nutzen für alle!David Decker · deckerweb.de · WP Camp 2012
  5. 5. Implementieren Für Text-Strings:Textdomain laden: Regulär:load_textdomain() __()load_plugin_textdomain() _e()load_theme_textdomain() _x()load_child_theme_textdomain() _ex() _n() Spezial: Sicherheit: _n_noop() esc_html__() translate_nooped_plural() esc_html_e() _nx_noop() esc_html_x() number_format_i18n() esc_attr__() date_i18n() esc_attr_e() esc_attr_x()David Decker · deckerweb.de · WP Camp 2012
  6. 6. dein-plugin.php Kopfbereich, Metadaten:Plugins: /** * Text Domain: dein-plugin-name-slug * Domain Path: rel-sprachdatei-pfad */add_action( init, ddw_wpcamp_plugin );function ddw_wpcamp_plugin() { load_plugin_textdomain( deine-textdomain, false,dirname( plugin_basename( __FILE__ ) ) . /languages/ );} Hook „init“ am besten (WMPL!), „plugins_loaded“ ginge wohl auch evtl. Priorität ändern! (experimentieren!) Zusatz: dirname( plugin_basename( __FILE__ ) ) ./languages/ könnte gefiltert werden (bei Plugins relative Pfadebeachten!)David Decker · deckerweb.de · WP Camp 2012
  7. 7. style.css Kopfbereich, Metadaten:Themes: /* Text Domain: dein-theme-name-slug Domain Path: rel-sprachdatei-pfad */add_action( init, ddw_wpcamp_theme );function ddw_wpcamp_theme() { load_theme_textdomain( deine-textdomain,get_template_directory() . /languages/ );} Hook „init“ am besten (WMPL!), „after_setup_theme“ evtl. auch evtl. Priorität ändern! (experimentieren!) Zusatz: get_template_directory() . /languages/ solltegefiltert werdenDavid Decker · deckerweb.de · WP Camp 2012
  8. 8. style.css Kopfbereich, Metadaten:Child /* Text Domain: dein-child-theme-slug Domain Path: rel-sprachdatei-pfadThemes: */add_action( init, ddw_wpcamp_child_theme );function ddw_wpcamp_child_theme() { load_child_theme_textdomain( deine-child_textdomain,get_stylesheet_directory() . /languages/ );} Hook „init“ am besten (WMPL!), „after_setup_theme“ evtl. auch evtl. Priorität ändern! (experimentieren!) Zusatz: get_stylesheet_directory() . /languages/ könntegefiltert werdenDavid Decker · deckerweb.de · WP Camp 2012
  9. 9. Themes:Sprachdatei-Ordner filtern/** Set filter for parent themes languages directory */$parent_theme_lang_dir = get_template_directory() ./languages/;$parent_theme_lang_dir = apply_filters(parent_theme_lang_dir, $parent_theme_lang_dir );add_action( init, ddw_wpcamp_theme );function ddw_wpcamp_theme() { load_theme_textdomain( deine-textdomain,$parent_theme_lang_dir );}David Decker · deckerweb.de · WP Camp 2012
  10. 10. Plugins vs. Themes:Dateinamen der SprachdateienThemes: Plugins:de_DE.mo /.po deine-textdomain-de_DE.mo /.ponl_NL.mo /.po deine-textdomain-nl_NL.mo /.pofi.mo /.po deine-textdomain-fi.mo /.po Lokale ermitteln: schau bei WPLANG in der wp-config.php! Oder hier recherchieren: http://codex.wordpress.org/WordPress_in_Your_LanguageDavid Decker · deckerweb.de · WP Camp 2012
  11. 11. Themes vs. Child Themes get_template_directory() vs. get_stylesheet_directory() load_textdomain() vs. load_child_theme_textdomain() (Child) Themes funktionieren aber auch mit load_textdomain() Streitfrage: Eigene Textdomains für Child Themes JA oder NEIN? DECKERWEB: JA, bitte eigene Domain für Child Themes!= klare Trennung = klarere Organisation = einfachere Pflege(Kundenprojekte...!)plus bessere PerformanceDavid Decker · deckerweb.de · WP Camp 2012
  12. 12. Syntaxbeispiele IKorrekt:Templates:<?php_e( Germany consists of 16 federal states,textdomain );?>In Funktionen:echo __( Germany consists of 16 federal states,textdomain );$string = __( Germany consists of 16 federal states,textdomain );David Decker · deckerweb.de · WP Camp 2012
  13. 13. Immer: Single Quotes!Syntaxbeispiele II EINE (1) Textdomain: String in Single QuotesFalsch:$string = __( $string, textdomain );$string = __( "Germany consists of $number federalstates", textdomain );$string = __( Germany consists of 16 federal states,$text_domain );$string = __( Germany consists of 16 federal states,PLUGIN_DOMAIN );$string = __( Germany consists of , textdomain ) .$number . __( federal states, textdomain );David Decker · deckerweb.de · WP Camp 2012
  14. 14. Syntaxbeispiele IIIErweitert: $string = sprintf( __( Germany consists of %d federal states, textdomain ), $number );$string = sprintf( _n( Germany consists of %d federalstate, Germany consists of %d federal states,$number, textdomain ), $number );$string = sprintf( __( I have %d bikes and %d cars,textdomain ), $bike_count, $car_count );$string = sprintf( __( I have %1$d bikes and %2$dcars, textdomain ), $bike_count, $car_count ); Hinweis: "%1$s" macht Probleme (PHP: $s !!!), daher Single QuotesDavid Decker · deckerweb.de · WP Camp 2012
  15. 15. Syntaxbeispiele IVKontext:$string = _x( Frankfurt, German city at the riverMain, textdomain );$string = _x( Frankfurt, German city at the riverOder, textdomain );$string = _x( Frankfurt, an asteroid, textdomain);David Decker · deckerweb.de · WP Camp 2012
  16. 16. Syntaxbeispiele VFormatierungen:$string = sprintf( __( <h1>I want %d Hefeweizen</h1>,textdomain ), $number );$string = <h1> . sprintf( __( I want %d Hefeweizen,textdomain ), $number ) . </h1>;$string = sprintf( __( I want %s Hefeweizen,textdomain ), <strong> . $number . </strong> ); Grundregel: KEINE oder so WENIG HTML-Formatierungen wie irgend möglich in den Übersetzungs-Strings!David Decker · deckerweb.de · WP Camp 2012
  17. 17. Syntaxbeispiele VISicherheit: Benutzereingaben: Ausgaben von Text in HTML-Attributen: esc_html__() esc_html_e() esc_attr__() esc_html_x() esc_attr_e() esc_attr_x()David Decker · deckerweb.de · WP Camp 2012
  18. 18. Syntaxbeispiele - Spezial INumerical No-op:$string = sprintf( _n( I have %d bike., You have %dbikes., $number, textdomain ), $number );$bikes_plural = _n_noop( I have %d bike., You have%d bikes., textdomain );$string = sprintf( translate_nooped_plural($bikes_plural, $number ) , $number );David Decker · deckerweb.de · WP Camp 2012
  19. 19. Syntaxbeispiele - Spezial IIZahlen & Daten:number_format_i18n()date_i18n()David Decker · deckerweb.de · WP Camp 2012
  20. 20. Häufige Fehler: Gar keine Übersetzbarkeit Übersetzbarkeit JA, aber kein „load_textdomain“ Mischen von Single & Double Quotes HTML in den Übersetzungs-Strings Falscher Einsatz von Platzhaltern/ Variablen Zu spätes Laden/ Einhängen der Sprachdatei, bzw. vergessenbei Fehlermeldungen/ Aktivierungs-Hooks etc. Eigene „Erfindungen“ fürs Laden der Sprachdateien Keine Verwendung von Kontext, Datum, Plural etc.David Decker · deckerweb.de · WP Camp 2012
  21. 21. Best Practices I ALLES Übersetzbar machen! Laden der Sprachdateien via Hook! Textdomain als String in Single Quotes setzen Generell nur Single Quotes HTML-Formatierungen raus aus den Strings!!! Beliebige Anordnung der Platzhalter ermöglichen via %1$d,%2$d etc. Sicherheit: ESCAPEN bei Benutzereingaben und bei Ausgabenin Attributen!David Decker · deckerweb.de · WP Camp 2012
  22. 22. Best Practices II Pfadangaben checken! load_textdomain() fordert absoluten Pfad load_plugin/theme/child_theme_textdomain() fordernrelativen Pfad BONUS 1: Sprachdatei-Ordner filterbar machen bzw.Zusätzlichen Ort für Update-sichere Sprachdateienbereitstellen BONUS 2: Ein GlotPress aufsetzen, um der Community dasÜbersetzen zu erleichtern... ;-)David Decker · deckerweb.de · WP Camp 2012
  23. 23. Werkzeuge: define( WP_DEBUG, true ); (wp-config.php) define( WPLANG, de_DE ); (wp-config.php) Plugin: „Codestyling Localization“ (zum eigentlichen Übersetzen) Software/ Installation: GlotPress (übersetzen, Export/Import.mo/.po, Verwalten) Lokale Software: PoEdit Editor (übersetzen, validieren -- gut fürPlatzhalter-Tests!) Testen! Testen! Testen!David Decker · deckerweb.de · WP Camp 2012
  24. 24. Codestyling LocalizationDavid Decker · deckerweb.de · WP Camp 2012
  25. 25. Codestyling LocalizationDavid Decker · deckerweb.de · WP Camp 2012
  26. 26. GlotPress InstallationDavid Decker · deckerweb.de · WP Camp 2012
  27. 27. GlotPress InstallationDavid Decker · deckerweb.de · WP Camp 2012
  28. 28. GlotPress InstallationDavid Decker · deckerweb.de · WP Camp 2012
  29. 29. PoEdit Editor (poedit.net)David Decker · deckerweb.de · WP Camp 2012
  30. 30. Verwendete Quellen: http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/ http://ottopress.com/2012/more-internationalization-fun/ http://genesisthemes.de/en/2011-12/seven-cardinal-sins-localizing-wordpress-plugins-themes/ http://codex.wordpress.org/I18n_for_WordPress_Developers http://pippinsplugins.com/localizing-and-translating-wordpress-plugins/ http://remkusdevries.com/how-to-use-glotpress-for-your-translations/David Decker · deckerweb.de · WP Camp 2012
  31. 31. Danke! Fragen jetzt! Folien unter: deckerweb.de/wpcamp2012 plus: slideshare.net/deckerweb David Decker @deckerweb +David Decker deckerweb.de deckerweb.de/sprachdateien translate.wpautobahn.comDavid Decker · deckerweb.de · WP Camp 2012
  32. 32. /** Call for break and add next session */add_action( wpcamp_berlin_2012, wpc_next_session_planning )function wpc_next_session_planning() { if ( is_break( array( 10min, coffee, wc ) ) ) { wpcamp_do_next_session(); echo __( Enjoy the break, wpcamp ); } else { wpcamp_do_celebrate_community(); echo __( Enjoy the conversation, wpcamp ); }}David Decker · deckerweb.de · WP Camp 2012

×