Multi-language & plugins

55 views
Skip to first unread message

ljk

unread,
Feb 20, 2013, 11:28:22 AM2/20/13
to joomla-de...@googlegroups.com
Hello,

I have a plugin which when it finds the Joomla user registration link redirects the user to the Virtuemart registration link. It works fine for a single language site, but for a multi-language site, it doesn't redirect to the correct language registration page. Does anyone know how I would do this so it goes to the correct language registration page?

Here is what I have in the code so far (this is for Joomal 2.5.x & VM 2.x):

        function onAfterRoute()
        {
                    // Get the application object.
                    $app = JFactory::getApplication();
                   
                    if ($app->isSite()) {
                        // if this is the front end, see if this is a registration page

                        if ( $app->input->get('option') == 'com_users' ) {
                            $view = $app->input->get('view', '');
                            $itemID = $app->input->get( 'Itemid', '' );
                            // Look for a registration link to Joomla! User manager
                            if ($view == 'registration') {
                                $menuid = $this->params->get("menuid", '');  // Get the menu id parameter
                                if ($menuid != '') {
                                    $url =    'index.php?option=com_virtuemart&view=user' . ( $Itemid ? '&Itemid=' . $Itemid : null );
                                } else {
                                    $url =    'index.php?option=com_virtuemart&view=user&Itemid=' . $menuid;
                                }
               
                                $app->redirect( JRoute::_( $url, false ), null, null, true, true );
                            }
                        }
                    }
       }

Thank you.

Aymeric Dourthe

unread,
Feb 20, 2013, 11:37:35 AM2/20/13
to joomla-de...@googlegroups.com
Hi,

why not using jLanguage to append lang parameter to your url :

Before : $app->redirect( JRoute::_( $url, false ), null, null, true, true );

$url = $url . '&lang=' . substr(jFactory::getLanguage()->getTag(), 0,2);

That should append language sef code to your url, if your code is well
name as 2 firsts characters of the language tag. Else you have to get
Sef Code.

Not tested but can work.


Best regards,
Aymeric Dourthe
Your web expert engineer

Le 20/02/2013 17:28, ljk a �crit :
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! General Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to joomla-dev-gene...@googlegroups.com.
> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

ljk

unread,
Feb 22, 2013, 1:13:36 PM2/22/13
to joomla-de...@googlegroups.com
Hi,

Thank you very much for your answer. I am giving it a try.

Is there any documentation anywhere on how to write an extension so that it is multi-lingual?

Thanks again.


On Wednesday, February 20, 2013 8:37:35 AM UTC-8, Fitz wrote:
Hi,

why not using jLanguage to append lang parameter to your url :

Before : $app->redirect( JRoute::_( $url, false ), null, null, true, true );

$url = $url . '&lang=' . substr(jFactory::getLanguage()->getTag(), 0,2);

That should append language sef code to your url, if your code is well
name as 2 firsts characters of the language tag. Else you have to get
Sef Code.

Not tested but can work.


Best regards,
Aymeric Dourthe
Your web expert engineer

Le 20/02/2013 17:28, ljk a �crit :
> an email to joomla-dev-general+unsub...@googlegroups.com.

JM Simonet

unread,
Feb 23, 2013, 3:22:26 AM2/23/13
to joomla-de...@googlegroups.com
Hello,

1. We have planned to create a tutorial for developers to make their components multilingual-aware for 3.x. This is especially important since associations are now implemented all over core.

2. Do not forget that some languages tag may include a 3 letters tag, like for example: ckb-IQ for Kurdish Sôrani.
A user making a multilanguage site may use "ku" as sef code
You should therefore always pick the SEF and not the lang tag.

You will get this using
$lang = JFactory::getLanguage();

$languages = JLanguageHelper::getLanguages();
then a foreach
then
$language->active = $language->lang_code == $lang->getTag();
etc.

Also, always use the conditional to check if multilingual is enabled
if (JLanguageMultilang::isEnabled())

mod_languages helper should be of help

JM


> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--

You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.

To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


-- 
Please keep the Subject wording in your answers
This e-mail and any attachments may be confidential. You must not disclose or use the information contained in this e-mail if you are not the
intended recipient. If you have received this e-mail in error, please notify us immediately and delete the e-mail and all copies.
-----------------------------------------------------------
Jean-Marie Simonet  /  infograf768
Joomla Production Working group
Joomla! Translation Coordination Team 

Brad Gies

unread,
Feb 23, 2013, 4:00:41 AM2/23/13
to joomla-de...@googlegroups.com

This is a question for anyone, but I'm assuming JM has the answer.

Has anyone thought or proposed writing a component to convert a uni-lingual site to a muli-lingual site using only the Joomla muli-language structure?

 I know about joomfish of course, but I haven't see anything that just uses the Joomla! way.

What I had in my head (scrambled as it may be) is a component that would run through the site, make a list of all categories, menu's, menu items, and content  for the "All" language or maybe the default language, and then duplicate all that structure for each enabled language.

Is there anything in the works?

Brad.

Sorry about the thread hijack :).

ljk

unread,
Feb 23, 2013, 9:59:05 PM2/23/13
to joomla-de...@googlegroups.com
Hi,

Thank you, that was very helpful.

I am not that familiar with the language part of Joomla. Would the code be like this:

if (JLanguageMultilang::isEnabled()) {

  $lang = JFactory::getLanguage();
  $languages = JLanguageHelper::getLanguages();
  // loop through the lanuguages looking for the one active on the frontend currently
  foreach ($languages as $language) {
    // Check to see if this is the active frontend language
    if ($language->lang_code == $lang->getTag()) {
      $url =    'index.php?option=com_virtuemart&lang='.$language->sef.'&view=user' . ( $Itemid ? '&Itemid=' . $Itemid : null );
    }
  }
} else {
  // code for non-multi-lingual site
}

Thanks again.

Is this the correct check to see if this is the currently active language on the frontend?
if ($language->lang_code == $lang->getTag())

> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.

To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages