This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

samsosclass

  • **
  • 29 posts
Child Theme Translations (.po and .mo files)
« on: November 26, 2020, 01:00:24 AM »
Hello,
So ive got a child theme with the beta theme and everything works perfectly fine when I click the preview button to see the preview of the theme. but when i click activate the translation files are not being used for the text, it is using the default translations. It is strange how it works on the preview but when i click activate child theme it goes back to the default translation. is this a bug? or have i not updated another relevant file somewhere for it to read translations in the child theme folder.

Kind Regards
« Last Edit: November 26, 2020, 09:43:30 AM by MB Themes »

*

MB Themes

Re: Child Theme Translations (.po and .mo files)
« Reply #1 on: November 26, 2020, 09:41:59 AM »
@samsosclass
In same way as it is done in default theme you should try to do it in child theme.
Keep in mind that i.e. in beta, if you have function to print text like this:
Code: [Select]
__('Some text', 'beta');
_e('Some text', 'beta');

This should probably be changed into:
Code: [Select]
__('Some text', 'beta_child');
_e('Some text', 'beta_child');

As if you look here:
https://osclasspoint.com/blog/osclass-create-child-theme-b21

themename is being changed to themename_child (folder)

Next step should be to copy languages folder into child theme. Then you open .po file and in Catalog > Properties > Source paths, you ensure it's set to languages\en_US\  (or your locale ... cs_CZ, de_DE, fr_FR, ...).
Save .po file and click on Catalog > Update from source code, this will get all strings used in child themes. It should be much less than you had in original theme, as you do not copy every file from original theme.

Once done, upload new language files (.po & .mo) into child theme.

It should work now if it is done properly in core, but I think it has never been explored completely, there was never any good tutorial better than is at osclasspoint.com, you may let us know about results ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

samsosclass

  • **
  • 29 posts
Re: Child Theme Translations (.po and .mo files)
« Reply #2 on: November 26, 2020, 02:34:02 PM »
Hello Im trying everything when it comes to putting the .po and .mo files in the language files but it just doesnt seem to be working when i activate the child theme

*

MB Themes

Re: Child Theme Translations (.po and .mo files)
« Reply #3 on: November 26, 2020, 02:47:32 PM »
Try to identify from which file translations are taken.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

samsosclass

  • **
  • 29 posts
Re: Child Theme Translations (.po and .mo files)
« Reply #4 on: November 26, 2020, 02:48:44 PM »
I did that, i renamed every single file in core and in all themes and the original was still showing i have no idea what seems to be overiding it or using from

*

samsosclass

  • **
  • 29 posts
Re: Child Theme Translations (.po and .mo files)
« Reply #5 on: November 26, 2020, 03:03:03 PM »
I have completely changed the PO and MO files in the child theme but it doesnt want to read it from there

*

samsosclass

  • **
  • 29 posts
Re: Child Theme Translations (.po and .mo files)
« Reply #6 on: November 26, 2020, 03:10:56 PM »
Is there a video tutorial on this or a clear step by step for child theme translations ? because its just the translations that seem to be the problem.


*

MB Themes

Re: Child Theme Translations (.po and .mo files)
« Reply #7 on: November 26, 2020, 03:24:28 PM »
@samsosclass
There is no tutorial or docs regarding child themes
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

samsosclass

  • **
  • 29 posts
Re: Child Theme Translations (.po and .mo files)
« Reply #8 on: November 26, 2020, 03:49:35 PM »
What else can  try to get this working then?

Kind Regards

*

samsosclass

  • **
  • 29 posts
Re: Child Theme Translations (.po and .mo files)
« Reply #9 on: November 26, 2020, 03:51:51 PM »
Because the text that i need to change in beta doesnt come from the functions, it comes from the translation files so im having to do a translation in order to change default text on the website such as the opening text above the search on the home page of beta. There doesnt seem to be another way of changing this text anywhere other than translation files. and shild theme doesnt want to listen to translation files.

*

samsosclass

  • **
  • 29 posts
Re: Child Theme Translations (.po and .mo files)
« Reply #10 on: November 26, 2020, 04:22:22 PM »
hello looks like the translation files are still being used from the main beta theme file so how do i get it using the child one?

*

samsosclass

  • **
  • 29 posts
Re: Child Theme Translations (.po and .mo files)
« Reply #11 on: November 26, 2020, 04:24:05 PM »
but then when child theme is activated it doesnt use either one of them by the looks of it

*

MB Themes

Re: Child Theme Translations (.po and .mo files)
« Reply #12 on: November 26, 2020, 04:40:17 PM »
When I will have time, will take a look on it. There could be also problem in core.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

samsosclass

  • **
  • 29 posts
Re: Child Theme Translations (.po and .mo files)
« Reply #13 on: November 26, 2020, 04:48:55 PM »
Hello, thank you, because i cant update my beta theme which i paid for because of this at the moment.

Marked as best answer by frosticek on November 26, 2020, 06:35:25 PM
*

MB Themes

Re: Child Theme Translations (.po and .mo files)
« Reply #14 on: November 26, 2020, 06:34:36 PM »
@samsosclass
Ok I've done a lot of testing, and outcome is:
- let's consider we have sigma theme and sigma_child theme
- to make translations working properly, languages folder must be created in sigma_child
- if languages folder does not exists, osclass takes oc-content/languages folder
- to ensure osclass takes translations from child languages file, functions in php files must use domain 'sigma_child', not 'sigma'
- this means it is not possible to properly use child themes with translations (you would need to create all files and change translation domain)

This is completely missing in osclass now, to consider parent theme for child as well.
I've done some development and this will be fixed in 4.2.0 version, and will work in this way:
- first, it will load parent theme translations and apply it on everything with domain 'sigma', even it is used in child theme as well
- next, it will load child theme translations and apply it on everything with domain 'sigma_child'

This will basically merge different translation files and allow to use full potential of child themes.

I've done demo and created child for home page on sigma there
https://dev7.abprofitrade.eu/

<?php _e('All locations', 'sigma'); ?>  ---> loads translation from oc-content/themes/sigma/languages
<?php _e('All categories', 'sigma_child'); ?>  ---> loads translation from oc-content/themes/sigma_child/languages

Both used in same file main.php
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots