WordPress.org

Support

Support » Themes and Templates » Language files in a theme

Language files in a theme

  • mailcatala
    Member

    @mailcatala

    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Frumph
    Participant

    @frumph

    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

    mailcatala
    Member

    @mailcatala

    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Language files in a theme’ is closed to new replies.