How to show content items based on selected culture in "Translate" page (module "Orchard.Localization")?

Topics: Localization
Jun 18, 2013 at 1:41 PM
Edited Jun 18, 2013 at 1:42 PM
I created content type "Product" and "Promotion" and "Product" has "ProductPart" that reference to content item "Promotion".

In "Create/Edit Product" page, UI will show available list for "Promotions" and user can select multiple "Promotions.

Problem
When I click "New Translate" for selected "Product", I see drop down list "Content Localization" that show all cultures in the site. When I change this drop down list, I would like to show "Promotions" that have same selected culture.

But when I debug in the module "Orchard.Localization". I found that when user changes drop down list for cultures, it does not post back to any controller class or any driver class.

Questions
  1. Can we listen event (in our module) that user change drop down list for cultures (in module "Orchard.Localization")?
  2. Do we need to modify module "Orchard.Localization" to support this case? If so, could you please suggest me how does our module listen for event that user change drop down list for cultures?
Developer
Jun 20, 2013 at 11:48 PM
Let me summarize it: you want to do something when the user changes the value of the culture dropdown, visible when you want to add a new translation to a content item (through LocalizationPart). Right?
  1. Yes.
  2. No, you don't need to modify Orchard.Localization.
You can hook into the onchanged event of that dropdown from javascript. Now the question is how to add your JS to editors where that dropdown appears. The most simple approach I can currently think of is to:
  1. Create your own driver for LocalizationPart (parts can have an arbitrary number of drivers) in your own module.
  2. Implement the GET Editor method.
  3. In the corresponding editor shape include your script (either as inline JS or from an external script).