Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:27:56+00:00 2026-06-07T10:27:56+00:00

When using gettext in WordPress to create a bilingual theme, do we have to

  • 0

When using gettext in WordPress to create a bilingual theme, do we have to create one .php file for every page twice (English, French)? For example, header.php, header-fr.php, sidebar.php, sidebar-fr.php, taxonomy-types.php, taxonomy-types-fr.php, etc. Sidebar-fr.php would then use _e(‘Text to translate’, ‘domain’). Is there a way to simply keep one copy of all php files and to switch the locale?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:27:58+00:00Added an answer on June 7, 2026 at 10:27 am

    Create languages folder inside the theme directory, that’s where you save language files, e.g. ar.po (for Arabic).
    When writing strings in the code use the following (I usually use English text as the default text, so I won’t need to create extra language file, and for each other language create files):

    <?php echo __('This is a test','my_theme_name'); ?>
    <?php _e('This is a test','my_theme_name'); ?>
    

    in functions.php in the theme folder add the following code to load the language file (please note my_theme_name as given above):

    add_action( 'after_setup_theme', 'my_theme_setup' );
    function my_theme_setup(){
    
        load_theme_textdomain('my_theme_name', get_template_directory() . '/languages');
    
    }
    

    This way you create only one file(header.php, index.php, etc), where strings are easy to translate.

    [Note: this answer assumes that you have knowledge in how to create gettext translation files]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using gettext in my PHP code, but I have a big problem.
From my previous questions about gettext, one of the biggest benefits of using PHP's
I have a PHP application using Gettext as the i18n engine. The translation works
I am using gettext for a large PHP project. I have successfully setup everything,
I am localizing some PHP/XHTML using the gettext() function in a WordPress plugin. WordPress
I'm using gettext in a MAMP environment. I have locale files for es_ES ,
I am currently translating my PHP application using gettext with POEdit. Since I respect
I've written a .po file for my wordpress theme. The charset is unicode as
I'm currently doing internationalization with gettext using PHP. I was wondering if there were
To clarify: I'm not using the gettext php module /extension, reason being because I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.