Advertisement:

Author Topic: categories translation  (Read 7508 times)

gtounsi

  • Newbie
  • *
  • Posts: 9
categories translation
« on: October 16, 2013, 09:46:46 am »
Hello, im using modern theme with two languages french and english. The theme works with the english language and doesn't work with french language. Categories in english cannot be translated into french.  Can someone help me to solve this issue?
« Last Edit: October 16, 2013, 09:48:20 am by gtounsi »

teseo

  • Hero Member
  • *****
  • Posts: 6168
Re: categories translation
« Reply #1 on: October 16, 2013, 01:17:01 pm »
Hi,

What version of Osclass?

Regards

gtounsi

  • Newbie
  • *
  • Posts: 9
Re: categories translation
« Reply #2 on: October 16, 2013, 10:50:54 pm »
i use Osclass 3.1.2 version.
thanks for your support

teseo

  • Hero Member
  • *****
  • Posts: 6168
Re: categories translation
« Reply #3 on: October 17, 2013, 12:45:14 am »
***OBSOLETE, better solution in the post below:***

http://forums.osclass.org/modern/categories-translation/msg116959/#msg116959

***************************


You need to slightly modify a core file, let's try this:

oc-includes\osclass\model\Category.php Line 127

Code: [Select]
        public function listEnabled()
        {
            $this->dao->select( sprintf("a.*, b.*, c.i_num_items, FIELD(fk_c_locale_code, '%s') as locale_order", $this->dao->connId->real_escape_string(osc_current_user_locale()) ) );
            $this->dao->from( $this->getTableName().' as a' );
            $this->dao->join(DB_TABLE_PREFIX.'t_category_description as b', 'a.pk_i_id = b.fk_i_category_id', 'INNER');
            $this->dao->join(DB_TABLE_PREFIX.'t_category_stats  as c ', 'a.pk_i_id = c.fk_i_category_id', 'LEFT');
            $this->dao->where("b.s_name != ''");
            $this->dao->where("a.b_enabled = 1");

Add below:

           
Code: [Select]
$this->dao->where(sprintf("b.fk_c_locale_code = '%s'", $this->dao->connId->real_escape_string(osc_current_user_locale()) ) );
This is working for me, but I have made many modifications for my current project and don't know if something more is required, ??? so you tell me if it works for you and this might be considered a standard solution...

Regards
« Last Edit: March 03, 2015, 01:12:58 am by teseo »

gtounsi

  • Newbie
  • *
  • Posts: 9
Re: categories translation
« Reply #4 on: October 18, 2013, 02:33:15 pm »
Its works now. thanks for your support.
Gillis.

teseo

  • Hero Member
  • *****
  • Posts: 6168
Re: categories translation
« Reply #5 on: October 18, 2013, 03:33:58 pm »
Glad to be of help. :)

Remember that you must manually redo this modification in case of Osclass upgrade.

Please add [SOLVED] to the title of this thread for it to be useful for others forum fellows.

Regards

Heisenberg

  • Newbie
  • *
  • Posts: 16
Re: categories translation
« Reply #6 on: March 01, 2015, 01:22:15 pm »
thank you :D

Heisenberg

  • Newbie
  • *
  • Posts: 16
Re: categories translation
« Reply #7 on: March 03, 2015, 12:25:33 am »
sub categories no translate :(

teseo

  • Hero Member
  • *****
  • Posts: 6168
Re: categories translation
« Reply #8 on: March 03, 2015, 01:11:13 am »
Hi,

???

I think they should, although anyway this modification I wrote above is not enough. I've proposed a more complete modification of oc-includes/osclass/model/Category.php, try replacing that whole file with this one:

https://raw.githubusercontent.com/teseo-2014/Osclass-develop/develop/oc-includes/osclass/model/Category.php

Now, being a core file, remember that you'll need to redo this modification every time you upgrade Osclass (unless they eventually accept my request, or solve this issue on their own). ???

Regards

SteveJohnson

  • Sr. Member
  • ****
  • Posts: 328
  • Golden tip - Clear your cache :|
Re: categories translation
« Reply #9 on: September 08, 2017, 08:39:25 pm »
Hi,

???

I think they should, although anyway this modification I wrote above is not enough. I've proposed a more complete modification of oc-includes/osclass/model/Category.php, try replacing that whole file with this one:

https://raw.githubusercontent.com/teseo-2014/Osclass-develop/develop/oc-includes/osclass/model/Category.php

Now, being a core file, remember that you'll need to redo this modification every time you upgrade Osclass (unless they eventually accept my request, or solve this issue on their own). ???

Regards

Hi teseo,
I just moved to another host, and i don't see the category names anymore on my site. I see the default categories that osclass ships with.
When i do the setup again on the previous host, i see the my correct categories again.

I just tried to replace your file with the standard core file, and it works!

Could you tell me what different does your code do? I just wanted to keep in mind since i'm modifying core files, and need to keep the changes in mind.

Thanks!
 

teseo

  • Hero Member
  • *****
  • Posts: 6168
Re: categories translation
« Reply #10 on: September 12, 2017, 03:57:55 pm »
Hi,

This is a problem when you use MariaDB instead of standard MySQL, the vanilla query gives a wrong result on MariaDB. My mod replaces that query with another one, compatible with both. It's working but maybe I made the new query too complicated (with fallback to english and other alternative languages when category translation is not found for the active language), the Osclass team seems to have a simpler alternative here (still in develop phase):

https://github.com/osclass/Osclass/pull/2034

And here the modified Category.php proposal:

https://raw.githubusercontent.com/osclass/Osclass/4a4d05059f3bc6c531fe1b03c33dc41b52e08b28/oc-includes/osclass/model/Category.php

This method is faster than mine, but no fallback to english (as it is now on official version), so you need to make sure that all of your categories are translated for all your languages (if no translation for the current language, category won't be shown at all).

Regards

SteveJohnson

  • Sr. Member
  • ****
  • Posts: 328
  • Golden tip - Clear your cache :|
Re: categories translation
« Reply #11 on: October 27, 2017, 04:08:03 am »
Hi,

This is a problem when you use MariaDB instead of standard MySQL, the vanilla query gives a wrong result on MariaDB. My mod replaces that query with another one, compatible with both. It's working but maybe I made the new query too complicated (with fallback to english and other alternative languages when category translation is not found for the active language), the Osclass team seems to have a simpler alternative here (still in develop phase):

https://github.com/osclass/Osclass/pull/2034

And here the modified Category.php proposal:

https://raw.githubusercontent.com/osclass/Osclass/4a4d05059f3bc6c531fe1b03c33dc41b52e08b28/oc-includes/osclass/model/Category.php

This method is faster than mine, but no fallback to english (as it is now on official version), so you need to make sure that all of your categories are translated for all your languages (if no translation for the current language, category won't be shown at all).

Regards

Hi Teseo,
I was not using MariaDB, but i was using Percona on the old server. On the new server however, i use Mysql 5.7 now

safeacid

  • Jr. Member
  • **
  • Posts: 64
Re: categories translation
« Reply #12 on: February 03, 2018, 06:59:21 pm »
***OBSOLETE, better solution in the post below:***

http://forums.osclass.org/modern/categories-translation/msg116959/#msg116959

***************************


You need to slightly modify a core file, let's try this:

oc-includes\osclass\model\Category.php Line 127

Code: [Select]
        public function listEnabled()
        {
            $this->dao->select( sprintf("a.*, b.*, c.i_num_items, FIELD(fk_c_locale_code, '%s') as locale_order", $this->dao->connId->real_escape_string(osc_current_user_locale()) ) );
            $this->dao->from( $this->getTableName().' as a' );
            $this->dao->join(DB_TABLE_PREFIX.'t_category_description as b', 'a.pk_i_id = b.fk_i_category_id', 'INNER');
            $this->dao->join(DB_TABLE_PREFIX.'t_category_stats  as c ', 'a.pk_i_id = c.fk_i_category_id', 'LEFT');
            $this->dao->where("b.s_name != ''");
            $this->dao->where("a.b_enabled = 1");

Add below:

           
Code: [Select]
$this->dao->where(sprintf("b.fk_c_locale_code = '%s'", $this->dao->connId->real_escape_string(osc_current_user_locale()) ) );
This is working for me, but I have made many modifications for my current project and don't know if something more is required, ??? so you tell me if it works for you and this might be considered a standard solution...

Regards

Hello
Recently I back-up my osclass and moved data to other server. I had problem with same issue.

Both solutions are OK, but the solution where need to replace whole Category.php I found not very reliable.
The waiting time has increased from 1,2 seconds to 6 seconds for pass php before it starts to send html back.
I have 2300 categories.

On ngnix all is working fine but on apache I had the problem, but as you said, there is no problem with server, but still this the question remains for me open, why on one server all working fine on other - problem with categories translation.
No any installation was done, just transfer back up to new server + import sql data....hm...

But thanks again for sharing, this one line save me life:)


teseo

  • Hero Member
  • *****
  • Posts: 6168
Re: categories translation
« Reply #13 on: February 04, 2018, 01:43:46 pm »
Hi,

See this post, the official fix should be faster than mine:

https://forums.osclass.org/modern/categories-translation/msg155388/#msg155388

Regards

safeacid

  • Jr. Member
  • **
  • Posts: 64
Re: categories translation
« Reply #14 on: February 04, 2018, 08:42:11 pm »
teseo thanks :)

Ill try )