Advertisement:

Author Topic: One domain name per language switch  (Read 1169 times)

mecene

  • Newbie
  • *
  • Posts: 2
One domain name per language switch
« on: May 12, 2017, 02:16:12 pm »
Good morning,
I am currently trying to set up a classified site which has one domain name per language.
Unfortunately, I can't find a way to have it working properly.
The language switch href links have différents domain names, it refuses to change the page domain.

Goal :
domain.com -> en_US
domain.fr     -> fr_FR

and the language switcher should redirect to the related domain.

So far :


  • Two domains (.com and .fr) pointing to the server.
  • Setup the native osclass permalink option (Htaccess amended)
  • Modified "/oc-includes/osclass/helpers/hpreference.php" to set language according to domain:
    function osc_language() { //mecene language domain name
        if($_SERVER['HTTP_HOST'] == 'domain.fr'){
            return('fr_FR');
        }else{
            return(getPreference('language')); // default en_US if .com
        }
       
    }


  • Modified "/oc-includes/osclass/helpers/hDefine.php" to change urls of the language switcher :
    function osc_change_language_url($locale) {

        $baseUrlEn = 'http://domain.com/';
        $baseUrlFr = 'http://domain.fr/';

        if ( osc_rewrite_enabled() ) {
                        switch ($locale) {
                case 'en_US':
                        return $baseUrlEn . osc_get_preference('rewrite_language') . '/' . $locale;
                    break;
             
                case 'fr_FR':
                        return $baseUrlFr . osc_get_preference('rewrite_language') . '/' . $locale;
                    break;
             
                default:
                        return osc_base_url() . osc_get_preference('rewrite_language') . '/' . $locale;
                    break;
            }
            //return osc_base_url() . osc_get_preference('rewrite_language') . '/' . $locale;
        } else {

            return osc_base_url(true) . '?page=language&locale=' . $locale;
        }
    }


This last code gives me the right links Url on the language switch but when I clic it nothing happens.
Could anyone help me with this issue or at least guide me to the right path or let me know that i am doomed with this crazy idea.

Kind regards

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: One domain name per language switch
« Reply #1 on: September 19, 2018, 10:27:33 pm »
hey mecene,
did you find a solution for this to work?

andresvendedor

  • Jr. Member
  • **
  • Posts: 59
Re: One domain name per language switch
« Reply #2 on: November 21, 2018, 03:19:41 pm »
I have done something similiar. I remved the language swithcer and replaced them with links to the root of each language.