2580 posts Put a Donk On It
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 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
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
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');
2580 posts Put a Donk On It
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 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
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
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' );
2580 posts Put a Donk On It
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 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 sold $125,000+ on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
+10 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
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
unisphere says
2580 posts Put a Donk On It
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 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 sold $125,000+ on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
+10 more
JamiGibbs says

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

2580 posts Put a Donk On It
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 more
ThemeProvince says

Still can’t get it working :(

@unisphere So you dont provide translations for the admin?

by
by
by
by
by
by