2566 posts Put a Donk On It
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • United Kingdom
  • Exclusive Author
  • Attended a Community Meetup
  • Repeatedly helped protect Envato Market against copyright violations
  • Referred between 200 and 499 users
+5 more
ThemeProvince says

Hey guys,

I am localizing a theme. I can successfully translate strings on the frontend but not in the admin.

I have entered _x in the keywords also.

The text domain is brandspace.

This is the code I am using:


add_action('init', 'codex_custom_init');
function codex_custom_init() 
{
  $labels = array(
    'name' => _x('Books', "brandspace"),
    'singular_name' => _x('Book', "brandspace"),
    'add_new' => _x('Add New', 'brandspace'),
    'add_new_item' => __('Add New Book'),
    'edit_item' => __('Edit Book'),
    'new_item' => __('New Book'),
    'all_items' => __('All Books'),
    'view_item' => __('View Book'),
    'search_items' => __('Search Books'),
    'not_found' =>  __('No books found'),
    'not_found_in_trash' => __('No books found in Trash'), 
    'parent_item_colon' => '',
    'menu_name' => 'Books'

  );
  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array('title','editor','author','thumbnail','excerpt','comments')
  ); 
  register_post_type('book',$args);
}

Regards

415 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 5-6 years
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
unisphere says

Hey, I haven’t personally used theme translation in the admin area, only on the frontend but one thing that comes to mind is are you loading the language files in the admin area with something like:

load_theme_textdomain('mytextdomain', get_template_directory() . '/languages');
2566 posts Put a Donk On It
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • United Kingdom
  • Exclusive Author
  • Attended a Community Meetup
  • Repeatedly helped protect Envato Market against copyright violations
  • Referred between 200 and 499 users
+5 more
ThemeProvince says

This is my current code for loading the text domain:


load_theme_textdomain( 'brandspace' , TEMPLATEPATH);
$locale = get_locale();
$locale_file = TEMPLATEPATH . "/$locale.php";
if ( is_readable( $locale_file ) ) require_once( $locale_file );

Only frontend strings are being translated.

415 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 5-6 years
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
unisphere says

Hi, create a /languages/ folder inside your theme’s root folder, copy the .MO files into it and use the following code:

load_theme_textdomain( 'brandspace', TEMPLATEPATH . '/languages' );
2566 posts Put a Donk On It
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • United Kingdom
  • Exclusive Author
  • Attended a Community Meetup
  • Repeatedly helped protect Envato Market against copyright violations
  • Referred between 200 and 499 users
+5 more
ThemeProvince says
unisphere said
Hi, create a /languages/ folder inside your theme’s root folder, copy the .MO files into it and use the following code:
load_theme_textdomain( 'brandspace', TEMPLATEPATH . '/languages' );

Sorry that didn’t work :(

1950 posts Do the Needful
  • Has been a member for 4-5 years
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • United States
  • Has attended an Envato Live event
  • Author had a Free File of the Month
  • Envato Studio (Microlancer) Beta Tester
  • Contributed a Blog Post
  • Beta Tester
+6 more
JamiGibbs says

Where are you adding ‘load_theme_textdomain’? Try putting it at the top of the custom post type file:


load_theme_textdomain('brandspace');

415 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 5-6 years
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
unisphere says
2566 posts Put a Donk On It
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • United Kingdom
  • Exclusive Author
  • Attended a Community Meetup
  • Repeatedly helped protect Envato Market against copyright violations
  • Referred between 200 and 499 users
+5 more
ThemeProvince says
JamiGibbs said
Where are you adding ‘load_theme_textdomain’? Try putting it at the top of the custom post type file:

load_theme_textdomain('brandspace');

At the top of functions.php

@unisphere Thanks for your help!

1950 posts Do the Needful
  • Has been a member for 4-5 years
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • United States
  • Has attended an Envato Live event
  • Author had a Free File of the Month
  • Envato Studio (Microlancer) Beta Tester
  • Contributed a Blog Post
  • Beta Tester
+6 more
JamiGibbs says

Try adding it to the top of the custom post file.

2566 posts Put a Donk On It
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • United Kingdom
  • Exclusive Author
  • Attended a Community Meetup
  • Repeatedly helped protect Envato Market against copyright violations
  • Referred between 200 and 499 users
+5 more
ThemeProvince says

Still can’t get it working :(

@unisphere So you dont provide translations for the admin?

by
by
by
by
by
by