• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How to create a translation for a new child theme?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Internationalization and Translations › How to create a translation for a new child theme?

This topic is: not resolved

Tagged: child, gettext, i18n, internationalization, localization, textdomain, theme, translation

  • This topic has 2 replies, 2 voices, and was last updated 10 years ago by Stefano Garuti.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • January 17, 2013 at 5:37 am #12590
    Stefano Garuti
    Member

    Hallo,

    I need to provide a translation for a child theme I created from scratch.

    The strings in the theme are all enclosed the WP localization function with their own textdomain (i.e. __('Some text','my_child_textdomain'), etc)

    The whole Genesis is translated using the tips by Remkus on his blog (here).

    Now I need your help 😉

    Do I need to create a new .po file?
    Where I have to put it (and the .mo file)? In my_child_dir/languages/ folder ?
    How can I "tell" to the child theme to load it? Do I have to use load_child_theme_textdomain() (I see it used in some child themes)

    Thanks for your help!

    Stefano


    Italian web e-learning, social media freelance and consultant
    WPMania.it | WP Video course

    January 21, 2013 at 1:14 am #13424
    David Decker
    Member

    Hi Stefano!

    Good topic, hehe 🙂

    You're already on the right path!
    You need to add the loading function for the textdomain just right after Genesis init function in child theme functions.php -- load it early before any strings are defined in child theme, that's best practice.

    Example:
    /** Set Localization (do not remove) */
    load_child_theme_textdomain( 'your-unique-textdomain', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'your-unique-textdomain' ) );

    --> as you can see here's already the path for the lang files defined, "/languages/" sub folder within child theme folder -- also best practice but you can use any path within child theme of course 🙂

    Actual lang files have the convention to only be named with the locale for themes & child themes, so for example: it_IT.mo and it_IT.po for Italian language. WP actually only needs the binary .mo file but it's best practice to also upload the .po file so you could edit it anytime you need it.

    As for the adding of the textdomain and Gettext syntax you did all right --- just remember to only use one unique textdomain for your child theme. Best practice here is to use the theme slug as the textdomain string. Do not use variables or constants here as this is not right here.

    If you did all the above you can then scan your child theme files with Poedit Editor to create a .pot file and then open the .pot catalog and create a .po file of it. Tip: enable "Create .mo file on saving" in Poedit settings so every time you hit save it creates/updates the actual .mo file.

    I hope that helps.
    -Dave 🙂


    Twitter @deckerweb // Google+ // My Genesis & WordPress Plugins // German Translations for Genesis

    January 21, 2013 at 2:14 am #13439
    Stefano Garuti
    Member

    David,

    thank you for your great post.

    Now I have all the information i need!

    Thank you again and have a good week!

    Stefano


    Italian web e-learning, social media freelance and consultant
    WPMania.it | WP Video course

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble