WordPress.org

Ready to get started?Download WordPress

Forums

Language files in a theme (3 posts)

  1. mailcatala
    Member
    Posted 1 year ago #

    I have a multilingual site where I want to add a translation for each theme available.

    Some questions on this subject:
    - What is the name of the file? As I understand, it has to be in a folder called language within the theme. Something like
    wp-content/themes/<my theme>/languages
    and the file should be called, for instance, en_EN.po (plus the necessary compiled en_EN.mo)

    - What is the syntaxis of the .po file? Do I have to mention the absolute path, the relative path to the root of WordPress or else to the root of the theme?

    #: wp-content/themes/<my theme>/<filename.ext>:109
    msgid "My Favorites"
    msgstr ""

    I am sure this has been resolved in another post but I have tried several searches and cannot find it. I would appreciate if you can save yourself from pointing me to a different thread.

    Thanks,

    AG

  2. Frumph
    Member
    Posted 1 year ago #

    Open the functions.php file of the theme and look for this function:

    load_theme_textdomain(

    It should look like this (with different info)

    load_theme_textdomain( 'easel', get_template_directory() . '/lang' );

    ^ the /lang or whatever it is in the theme you are using would be the directory that the language files go into

    If that isn't in your theme then there isn't any default support for languages in it

  3. mailcatala
    Member
    Posted 1 year ago #

    What about the syntax of the file itself? Do I have to write the path to the file as relative to the whole WordPress installation or else to the webserver?

    And how does it work for plugins?

Topic Closed

This topic has been closed to new replies.

About this Topic