Language detection with country support

naveenvalecha's picture

Hi Folks
I'm going to make a dependent module on i18n & countries module that add the option to add the choose country while choosing language and change the path prefix with the combination of langcode-countrycode in place of langcode.
Also provides the option on language configuration page to choose which countries are available for specific country.

Also I am gonna support the i18n country module support with all core entities.
Does anyone want to stop me? :) Are there any modules that makes same thing?

usefulness
This module is used at the places when we open a splash screen on the site and ask about the language and country and take user to the specific language & country page.

Thanks
Naveen Valecha

Comments

I recently did something

laboratory.mike's picture

I recently did something similar for a company and if you have any questions while developing I would be glad to give advice on building the module.

Here are a few thoughts:

  • Consider the possibility of being able to provide data with each country. We did this by creating a "country" content type so that we could add fields as needed. Otherwise, a means of per-country variables is a likely common need.
  • It should be possible to have "allowed languages" for each country.
  • Consider a global country switcher form + context set by said form.
  • With the language system, node-level translation used a "tnid" to mark canonical nodes. You may want to extend this with countries as well, perhaps countries are node-level and languages are field-level, which was our approach.
  • For permissions/filtering, we used OG to filter countries. You might consider OG integration, for editors on the backend as well as viewers on the front end.
  • Finally, hook_url_outbound_alter and hook_url_inbound_alter are your friends.

Share the code

naveenvalecha's picture

It would be awesome if you share the code and then it can become a good contrib project :)
I planned to do it for my company client, but after some requirement changes we go with multiple sites.
Below are some thoughts

  1. In hook_url_outbound_alter : if country & language are set, add the country code with the language code prefix.if not set then add the default country code with the language code prefix.
  2. In hook_url_inbound_alter : if county & language code are set, remove the country code with the language code prefix.if not set, remove the default country code with the language code prefix so that the flow of the other modules will work fine as it is working. .i.e. Reverse of the hook_url_outbound_alter .
  3. Submodule i18n_country_block :
    • Use hook_form_alter : Alter the block_add_block form to add the selection of the country.
    • Alter the block_custom_block_delete form to add the delete handler of this module to delete the data from custom table.
    • write the submit handler to save the data in the custom table
    • Keep a separate table for keeping the country codes with the block modulename,delta and country codes.
    • Write views filter handler for filtering the entities on the current user selected country.
    • Ctools access rules for country specific blocks.

Contributed Module Ideas

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week