• Resolved Guido

    (@guido07111975)


    Hi,

    Most themes and plugins use function load_theme_textdomain() or load_plugin_textdomain().
    And often with a path to a custom translation folder: load_theme_textdomain( 'my-theme', get_template_directory() . '/languages' );

    In Theme Handbook and Plugin Handbook I read this:

    As of version 4.6 WordPress automatically checks the language directory in wp-content for translations from translate.wordpress.org. This means that plugins that are translated via translate.wordpress.org do not require load_plugin_textdomain() anymore.
    If you don’t want to add a load_plugin_textdomain() call to your plugin you should set the Requires at least: field in your readme.txt to 4.6.

    Who can explain me why themes such as TwentyTwenty load a text domain, but without a path: load_theme_textdomain( 'twentytwenty' );

    It’s my understanding that this function is nowadays only useful in case of loading your own custom translation? This means including a path to a custom translation folder.

    Guido

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @guido07111975. You can read more about this feature in this Dev Note from 2016: https://make.wordpress.org/core/2016/07/06/i18n-improvements-in-4-6/

    My understanding is that the load_theme_textdomain( 'twentytwenty' ) in Twenty Twenty is redundant. The twentytwenty text domain would be loaded regardless once a call to __( ..., 'twentytwenty' ) is made.

    Thread Starter Guido

    (@guido07111975)

    Hi Robert,

    Thanks for your reply and the link. So it can be removed for themes and plugins that are listed in the WP repository. And if you ship your project with your own translation files you must add an additional function to load them.

    Guido

    If you ship your project with their own translation files, and you don’t want WP.org to effectively ignore them use, don’t use the WP.org slug. E.g. for a plugin my-plugin don’t use this as text domain use something like my-plugin-custom

    Otherwise 1) people will spend time translating things you don’t want translated and 2) when it reaches 80% it will override your translations

    There are other ways to stop WP auto translation, e.g. in a plugin header set requires to prior to 4.6. E.g. requires 3.0

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Translation – loading text domain’ is closed to new replies.