Localization / Internationalization of menus

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Localization / Internationalization of menus

grahamtk
This post has NOT been accepted by the mailing list yet.
Hi!
I have a question regarding using Monster Menus on a multi language site.
How would one go about it?

The most feasible way I see currently is to create a language subdomain,
and define this as a site in the admin/mm/sites page. Then this uniqe menu subtree will be assigned content when it is translated.

On a mm page in this subdomain I would like nodes shown in the correct language corresponding to the language in the subdomain name.  - but showing the correct language  would be handled by one of the language modules I hope.

What I would like to ask is wether it is possible to translate the manu as such? or to choose which language shlould be used to display nodes in a subtree?

Any other useful internationalization / language info is also welcome :)

Cheers.
Øyvind Graham
www.umb.no
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Localization / Internationalization of menus

Jay Dansand
Maybe one of the devs could comment, but I think a hook_menu_alter implementation changing $items['mm/%mm_mmtid'] to add the 'title callback' key pointing at your own function (defaults to t()) could have a shot at working.


Regards,
Jay Dansand, LU '08

--
 ____ ____    Senior Web Application Developer
||L |||U ||   Lawrence University ITS
||__|||__||   Office: 920-832-6585
|/__\|/__\|   Fax: 920-832-7693
              E-mail: [hidden email]


-----Original Message-----
From: grahamtk [mailto:[hidden email]]
Sent: Monday, October 01, 2012 8:38 AM
To: Monster Menus Development
Subject: Localization / Internationalization of menus

Hi!
I have a question regarding using Monster Menus on a multi language site.
How would one go about it?

The most feasible way I see currently is to create a language subdomain, and define this as a site in the admin/mm/sites page. Then this uniqe menu subtree will be assigned content when it is translated.

On a mm page in this subdomain I would like nodes shown in the correct language corresponding to the language in the subdomain name.  - but showing the correct language  would be handled by one of the language modules I hope.

What I would like to ask is wether it is possible to translate the manu as such? or to choose which language shlould be used to display nodes in a subtree?

Any other useful internationalization / language info is also welcome :)

Cheers.
Øyvind Graham
www.umb.no



--
View this message in context: http://monster-menus.2910260.n2.nabble.com/Localization-Internationalization-of-menus-tp7572710.html
Sent from the Monster Menus mailing list archive at Nabble.com.

---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=849053.214f550f57fa54a976b5f2d087b6d379&n=T&l=monster_menus&o=681862
or send a blank email to [hidden email]

---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=681863
or send a blank email to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localization / Internationalization of menus

Dan Wilga-2
In reply to this post by grahamtk
On 10/1/12 9:43 AM, Jay Dansand wrote:
> Maybe one of the devs could comment, but I think a hook_menu_alter implementation changing $items['mm/%mm_mmtid'] to add the 'title callback' key pointing at your own function (defaults to t()) could have a shot at working.
>
Unfortunately, I don't think that would work, Jay. The title of that
menu handler is never displayed anywhere, because it uses the
MENU_CALLBACK type. If it were displayed, you'd currently be seeing
'View' all over the place :-).

We have had some call to allow page names to be translated more easily,
but never got a formal request to do the programming. So I only have a
few ideas.

One easy way I can think of would be to override theme_mm_get_renderer:

function MYTHEME_mm_get_renderer() {
   if (!class_exists('MYTHEME_mmRenderer')) {
     module_load_include('inc', 'monster_menus', 'mm_renderer');
     class MYTHEME_mmRenderer extends mmRenderer {
       public function link_leaf($leaf, $item, $link_item) {
         $item['title'] = t($item['title']);
         return parent::link_leaf($leaf, $item, $link_item);
       }
     };
   }

   return new MYTHEME_mmRenderer();
}

I used the t() function, but you could just as easily use a different
function to do the translation. With this, the page titles will be
translated in the menus. That wouldn't handle the breadcrumbs, though.
That, you could do in MYTHEME_preprocess_page().

--
Dan Wilga                                 [hidden email]
Web System Administrator/Programmer             http://www.amherst.edu
Amherst College                                      Tel: 413-542-2175
Amherst, MA  01002


---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=681889
or send a blank email to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Localization / Internationalization of menus

Jay Dansand
In reply to this post by grahamtk
Oh gosh, if I had thought about it for a second I'd have remembered we sort of talked about dynamic titles and callbacks back in July, in regards to dynamic pages and hook_mm_showpage_routing().  I had a patch that changed titles in mm_showpage() but it had some drawbacks and didn't affect breadcrumbs or displayed menus.

Back then you'd suggested submitting the patch to mm_showpage(), which I didn't, but now I've used a different approach and I've submitted the patch as this issue: http://drupal.org/node/1801392

It's kind of a scary patch at first glance, but it's actually fairly small except I needed to modify 22 files to pass $mmtid (as described in the issue).  Those modifications could go away; the real meat of the matter is the added functionality in mm_content_expand_name().



Regards,
Jay Dansand, LU '08

--
 ____ ____    Senior Web Application Developer
||L |||U ||   Lawrence University ITS
||__|||__||   Office: 920-832-6585
|/__\|/__\|   Fax: 920-832-7693
              E-mail: [hidden email]


-----Original Message-----
From: Dan Wilga [mailto:[hidden email]]
Sent: Tuesday, October 02, 2012 8:32 AM
To: Monster Menus Development
Subject: Re: Localization / Internationalization of menus

On 10/1/12 9:43 AM, Jay Dansand wrote:
> Maybe one of the devs could comment, but I think a hook_menu_alter implementation changing $items['mm/%mm_mmtid'] to add the 'title callback' key pointing at your own function (defaults to t()) could have a shot at working.
>
Unfortunately, I don't think that would work, Jay. The title of that menu handler is never displayed anywhere, because it uses the MENU_CALLBACK type. If it were displayed, you'd currently be seeing 'View' all over the place :-).

We have had some call to allow page names to be translated more easily, but never got a formal request to do the programming. So I only have a few ideas.

One easy way I can think of would be to override theme_mm_get_renderer:

function MYTHEME_mm_get_renderer() {
   if (!class_exists('MYTHEME_mmRenderer')) {
     module_load_include('inc', 'monster_menus', 'mm_renderer');
     class MYTHEME_mmRenderer extends mmRenderer {
       public function link_leaf($leaf, $item, $link_item) {
         $item['title'] = t($item['title']);
         return parent::link_leaf($leaf, $item, $link_item);
       }
     };
   }

   return new MYTHEME_mmRenderer();
}

I used the t() function, but you could just as easily use a different function to do the translation. With this, the page titles will be translated in the menus. That wouldn't handle the breadcrumbs, though.
That, you could do in MYTHEME_preprocess_page().

--
Dan Wilga                                 [hidden email]
Web System Administrator/Programmer             http://www.amherst.edu
Amherst College                                      Tel: 413-542-2175
Amherst, MA  01002


---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=849053.214f550f57fa54a976b5f2d087b6d379&n=T&l=monster_menus&o=681889
or send a blank email to [hidden email]

---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=681914
or send a blank email to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localization / Internationalization of menus

grahamtk
In reply to this post by Dan Wilga-2
Thanks for this solution regarding translation of
menu entries.
   return new MYTHEME_mmRenderer();
This definetely solves my need for now - even though I see similar menu
entries in different sub menus
may get conflicting translations..

Words often have different meanings in different contexts
Like the menu item jobs, refering to Steve Jobs
would refer to job postings in the human resources department.
In norwegian we don't translate Jobs' surname, however, we do translate job
postings to 'stillinger'.

This can easily be solved in case of conflicting translations by
disambiguation in the menu names wich would improve the visiting users
understanding of the menu as well.

Can I get some pointers as to how to extend the new page form (where menu
name and url part is entered)?
So that the current page name field is for English and an additional field
got saved as the translation of the
English page name? (Preferably one field for each active language).

This would make the menu system perfect for multi language sites - unless
one wants to translate the actual urls as well.

Cheers!
Øyvind Graham



--
View this message in context: http://monster-menus.2910260.n2.nabble.com/Localization-Internationalization-of-menus-tp7572710p7572761.html
Sent from the Monster Menus mailing list archive at Nabble.com.

---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=690537
or send a blank email to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localization / Internationalization of menus

grahamtk
This post has NOT been accepted by the mailing list yet.
In reply to this post by Dan Wilga-2
Thanks for this solution regarding translation of
menu entries.
   return new MYTHEME_mmRenderer();
This definetely solves my need for now - even though I see similar menu entries in different sub menus
may get conflicting translations..

Words often have different meanings in different contexts
Like the menu item jobs, refering to Steve Jobs
would refer to job postings in the human resources department.
In norwegian we don't translate Jobs' surname, however, we do translate job postings to 'stillinger'.

This can easily be solved in case of conflicting translations by disambiguation in the menu names wich would improve the visiting users understanding of the menu as well.

Can I get some pointers as to how to extend the new page form (where menu name and url part is entered)?
So that the current page name field is for English and an additional field got saved as the translation of the
English page name? (Preferably one field for each active language).

This would make the menu system perfect for multi language sites - unless one wants to translate the actual urls as well.

Cheers!
Øyvind Graham
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localization / Internationalization of menus

Dan Wilga-2
In reply to this post by grahamtk
The easiest way to do this would be via MM's built-in cascaded settings
feature:

/**
  * Implements hook_form_FORMID_alter
  */
function MYMODULE_form_mm_ui_content_edit_alter(&$form, $form_state) {
   if (!isset($form['is_group']) &&
isset($form['additional_settings']['general'])) {
     // Gets saved automatically in mm_ui_content_edit_submit() because its
     // name matches a cascaded setting
     $form['additional_settings']['general']['translated_name'] = array(
       '#type' => 'textfield',
       '#title' => t('Translated Page Name'),
       '#default_value' => isset($form['is_new']) ? '' :
mm_content_get_cascaded_settings($form['path']['#value'],
'translated_name'),
     );
   }
}

/**
  * Implements hook_mm_cascaded_settings
  */
function MYMODULE_mm_cascaded_settings() {
   return array(
     'translated_name' => array(
       'data_type' => 'string',
     )
   );
}

For a given mmtid, you can get the setting using:

   mm_content_get_cascaded_settings($mmtid, 'translated_name')

Another way to do this would be using a "flag", as documented in
hook_mm_tree_flags(). This is a more efficient way to store and retrieve
the data, since it happens automatically in most cases. However, setting
up the form array to accept this value in the proper part of the form is
a bit tricky, since normally all flags are grouped together in their own
section that is only editable by admins.

On 6/18/13 1:40 AM, grahamtk wrote:

> Thanks for this solution regarding translation of
> menu entries.
>     return new MYTHEME_mmRenderer();
> This definetely solves my need for now - even though I see similar menu
> entries in different sub menus
> may get conflicting translations..
>
> Words often have different meanings in different contexts
> Like the menu item jobs, refering to Steve Jobs
> would refer to job postings in the human resources department.
> In norwegian we don't translate Jobs' surname, however, we do translate job
> postings to 'stillinger'.
>
> This can easily be solved in case of conflicting translations by
> disambiguation in the menu names wich would improve the visiting users
> understanding of the menu as well.
>
> Can I get some pointers as to how to extend the new page form (where menu
> name and url part is entered)?
> So that the current page name field is for English and an additional field
> got saved as the translation of the
> English page name? (Preferably one field for each active language).
>
> This would make the menu system perfect for multi language sites - unless
> one wants to translate the actual urls as well.
>
--
Dan Wilga                                 [hidden email]
Web System Administrator/Programmer             http://www.amherst.edu
Amherst College                                      Tel: 413-542-2175
Amherst, MA  01002


---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=690602
or send a blank email to [hidden email]
Loading...