Translation of child-theme

Feel free to talk about everything related to our Wordpress Products
Rate this topic: Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.
GK User
Tue Oct 22, 2013 7:48 pm
Hi,

I'm trying to translate my site to catalan (I already have my Wordpress in catalan), and I use a child-theme of the Publisher theme, so I've create the directory publisher-child/language and inside of it I created ca_ES.mo and ca_ES.po from the publisher.pot file. I also have set the language in wp-config.php:

Code: Select all
define ('WPLANG', 'ca_ES');


But It doesn't work....I've looking for information regarding this but it looks that I've done it correctly. :roll:
User avatar
Senior Boarder

GK User
Wed Oct 23, 2013 7:04 am
Hi,

Please try to do the same with your Publisher-parent theme, switch to your Publisher parent and check if translations is ok, If so, let me know and then I'll try to find the source of the problem with child theme.
User avatar
Moderator

GK User
Wed Oct 23, 2013 4:12 pm
I've activated Publisher parent theme and checked the following:

1- Noticed that catalan language files in my installation are called 'ca' not 'ca_ES'....so I defined the language in wp-config.php again to 'ca' as it originally was.
2 - Noticed that inside wp-content/languages there is a "themes" folder that contains twentyeleven-ca.mo, twentyeleven-ca.po, and so on....for the default themes of Wordpress. Not idea about that :?: :?:
3 - Edited back and forth ca.po (inside publisher/languages) to check if the changes have any effect, but it still doesn't work.
User avatar
Senior Boarder

GK User
Wed Oct 23, 2013 5:29 pm
Finally it worked on the Publisher parent theme, but it took quite a bit of time to update the frontend with the changes made in the .po file...why?? I cleared the cache everytime I refreshed the page.
User avatar
Senior Boarder

GK User
Wed Oct 23, 2013 6:11 pm
It seems to work on the child theme too.... :P But it takes a lot of time to update the frontend. :?: :?:
User avatar
Senior Boarder

GK User
Wed Oct 23, 2013 8:18 pm
Update of which exactly elements take a lot of time on the frontend? Widgets are cached, so maybe this is a problem, try to resave widgets or you'll have to wait cache time (60 minutes by default).
User avatar
Moderator

GK User
Thu Oct 24, 2013 9:04 am
Ah....that's it. When I resave the widget (NSP) the "read more" text reflects the changes I make in the .po file.....BUT although I've Publisher-child activated it only works when I edit the .po file inside Publisher parent theme.

I don't know why but language folder inside child-theme doesn't work.
User avatar
Senior Boarder

GK User
Thu Oct 24, 2013 9:57 am
Ok, When Publisher-child is activated, it inherits from parent so it's ok, transaltion works correctly, but if you'll copy language files to your child theme it should also works.

Try to edit your functions.php file from your Publisher-parent (you don't have to copy funcitons.php file to your child theme)

replace this line:
Code: Select all
load_theme_textdomain( $template_name, get_template_directory() . '/languages' );

with:
Code: Select all
load_theme_textdomain( $template_name, gavern_file( 'languages' );

Let me know if that helps.
User avatar
Moderator

GK User
Thu Oct 24, 2013 10:32 am
It give me some errors.....the line as you wrote it, gave me this erros when trying to save the NSP widget:
Code: Select all
( ! ) Parse error: syntax error, unexpected ';' in C:\wamp\www\wordpress\wp-content\themes\Publisher\functions.php on line 159
Call Stack
#   Time   Memory   Function   Location
1   0.0010   177632   {main}( )   ..\admin-ajax.php:0
2   0.0020   188464   require_once( 'C:\wamp\www\wordpress\wp-load.php' )   ..\admin-ajax.php:20
3   0.0020   195864   require_once( 'C:\wamp\www\wordpress\wp-config.php' )   ..\wp-load.php:29
4   0.0040   254256   require_once( 'C:\wamp\www\wordpress\wp-settings.php' )   ..\wp-config.php:90


I thought you missed one ending parentheses here:
Code: Select all
load_theme_textdomain( $template_name, gavern_file( 'languages' ));
Not sure because barely understand php code :mrgreen: ....changing that I could save the widget but appeared this error in the frontend:

Code: Select all
( ! ) Warning: Division by zero in C:\wamp\www\wordpress\wp-content\themes\Publisher-child\gavern\widgets.nsp.php on line 287
Call Stack
#   Time   Memory   Function   Location
1   0.0000   142592   {main}( )   ..\index.php:0
2   0.0000   144704   require( 'C:\wamp\www\wordpress\wp-blog-header.php' )   ..\index.php:17
3   0.3570   13026040   require_once( 'C:\wamp\www\wordpress\wp-includes\template-loader.php' )   ..\wp-blog-header.php:16
4   0.3720   13241688   include( 'C:\wamp\www\wordpress\wp-content\themes\Publisher\index.php' )   ..\template-loader.php:47
5   0.4780   13388088   gk_load( )   ..\index.php:16
6   0.4780   13396952   include( 'C:\wamp\www\wordpress\wp-content\themes\Publisher\layouts\before.php' )   ..\helpers.layout.php:33
7   0.4820   13398680   gk_dynamic_sidebar( )   ..\before.php:61
8   0.4860   13403104   call_user_func_array ( )   ..\helpers.layout.php:882
9   0.4860   13403336   WP_Widget->display_callback( )   ..\helpers.layout.php:882
10   0.4870   13408960   GK_NSP_Widget->widget( )   ..\widgets.php:182

( ! ) Warning: Division by zero in C:\wamp\www\wordpress\wp-content\themes\Publisher-child\gavern\widgets.nsp.php on line 289
Call Stack
#   Time   Memory   Function   Location
1   0.0000   142592   {main}( )   ..\index.php:0
2   0.0000   144704   require( 'C:\wamp\www\wordpress\wp-blog-header.php' )   ..\index.php:17
3   0.3570   13026040   require_once( 'C:\wamp\www\wordpress\wp-includes\template-loader.php' )   ..\wp-blog-header.php:16
4   0.3720   13241688   include( 'C:\wamp\www\wordpress\wp-content\themes\Publisher\index.php' )   ..\template-loader.php:47
5   0.4780   13388088   gk_load( )   ..\index.php:16
6   0.4780   13396952   include( 'C:\wamp\www\wordpress\wp-content\themes\Publisher\layouts\before.php' )   ..\helpers.layout.php:33
7   0.4820   13398680   gk_dynamic_sidebar( )   ..\before.php:61
8   0.4860   13403104   call_user_func_array ( )   ..\helpers.layout.php:882
9   0.4860   13403336   WP_Widget->display_callback( )   ..\helpers.layout.php:882
10   0.4870   13408960   GK_NSP_Widget->widget( )   ..\widgets.php:182
User avatar
Senior Boarder

GK User
Thu Oct 24, 2013 12:54 pm
I'm sorry, I forgot about ending parentheses. I just checked this and don't have this error, are you have a proper configuration of GK NSP widget? if you revert this line from functions.php this error disappears?

I'll check this exactly later, with language files.
User avatar
Moderator

GK User
Thu Oct 24, 2013 1:10 pm
Tried to change that line again, and the NSP widget worsk now but anyway it doesn't update the changes I make in .po file of the child theme. It only works with the .po file of the parent theme.
User avatar
Senior Boarder

GK User
Fri Oct 25, 2013 1:35 pm
Ok, I checked this with translation, and you should use this code in parent theme - functions.php file:
Code: Select all
load_theme_textdomain( $template_name, get_stylesheet_directory() . '/languages' );


Then, after activating Child theme, translations are taken form Child languages directory. But there's no need to copy functions.php file from your parent to child, your child theme inherits all functions from your parent theme, so only if yo want to write some new fuctions, you should do this, or even better use user.functions.php file.

In general, to your child theme you should copy only files that are changed by you.
User avatar
Moderator

GK User
Fri Oct 25, 2013 4:23 pm
It works in Publisher-child, but it doesn't work on other site in which I use a News-child theme.....I've done exactly the same (editing functions.php in parent theme and make changes to .po file in child theme).
User avatar
Senior Boarder

GK User
Fri Oct 25, 2013 7:28 pm
I don't understand, so it's working with Publisher theme, right? and you have another website with News theme and with News-child translation doesn't work?
User avatar
Moderator

GK User
Fri Oct 25, 2013 7:37 pm
That's it.
User avatar
Senior Boarder

GK User
Mon Oct 28, 2013 5:30 pm
Any idea?
User avatar
Senior Boarder

GK User
Mon Oct 28, 2013 6:27 pm
I checked this with News theme and translations works ok with Child theme, but problem is with GK NSP widget I think.. please check translations on category or single pages.

I need some time to debug this problem with GK NSP and News child theme.
User avatar
Moderator

GK User
Mon Oct 28, 2013 6:36 pm
I can't see the changes with the posts of a category neither.....http://wp.xeraco.es/category/arees-i-serveis/ "Read more" is still there.

By the way, I changed line 160 in parent theme - functions.php file, as you said earlier:

Code: Select all
load_theme_textdomain( $template_name, get_stylesheet_directory() . '/languages' );
User avatar
Senior Boarder

GK User
Mon Oct 28, 2013 6:56 pm
Strangely enough, in a contact form I can see all the text translated except from "Send message" that remains in English.....I don't know where is it taking the translations from because ca.po in News-child has all the texts translated (and is it not supossed to work) and ca.po in News parent doesn't seem to work neither.

You can see it here: http://wp.xeraco.es/parla-amb-lalcalde/
User avatar
Senior Boarder

GK User
Tue Oct 29, 2013 10:20 am
Could you send me a PM with backend and FTP access? i'll try to help.
User avatar
Moderator


cron