About
This module extends the language object and the Create and Edit forms for languages ​​by a new field.
With this new field, it is possible to define a ISO 3166-1 alpha-3 or UN M.49 Regioncode for your languages (e.g. "US" or "DE".)
With this module you can use IETF Language Tags in other modules or themes.

Usage Example
I needed this feature for a multilingual website I'm working on currently. With this module I can embed the Facebook JS API always in the correct language.

Project Page:
http://drupal.org/sandbox/michaelpetri/1965464

Git Repository:
git clone --branch 7.x-1.0 git.drupal.org:sandbox/michaelpetri/1965464.git language_region

Last but not least
I know this Project isn't really demanding and it has less than the requested 120 lines of code. I started this Project to get more familiar with git and how to contribute modules to drupal because i've some other great modules which I want to share with the community in the next weeks.

Comments

PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

bechtold’s picture

Hi michaelpetri,
especially because you want to learn git and stuff, first thing todo is to remove the master branch and set the default branch to 7.x-1.x:

Although master branches are commonly used in the Git world, the Drupal community uses major version branches (e.g., 7.x-1.x, 6.x-1.x) instead, since master does not indicate what Drupal version the project is compatible to.
The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.

In your git link above you can remove your username as well :-)

Your project page tells us not much and you are missing a README.txt.
Please add info about your module to both. Kind of in the way you have written in this application.

Your branch is 7.x-1.0 but as i understand the git workflow, your branch should be 7.x-1.x and 7.x-1.0 should only be a release tag.

Coder and pareview are throwing too many warnings at the moment.

I'm not sure if it's a good idea to make the language region code required, especially because it's not prefilled.

Maybe you could set locale as dependency to your .info file, as your module doesn't make much sense without languages :-)

You save the extra info into an extra table, isn't it possible to save that info directly into the languages table?
I'm not sure, if it's possible to influence other modules tables, but if, I think it would be the way to go.

Also very nice would be a file like the iso.inc prepared with codes for the default languages. Then the field could be prefilled.
If that file included different codes like ISO 3166-1 alpha-3 or UN M.49 you could give the user the option to just use one,
so he/she doesn't have to look them up.

But all together I like the idea of your module. It's sometimes helpful to differentiate btw. gb and us english or btw. swiss and german german.
One thing I'm not sure about though, the standard language code is an iso code already, isn't it?

Cheers
bechtold

bechtold’s picture

sorry, double post :-(

michaelpetri’s picture

Hi bechtold,

first of all thanks for your kind feedback and telling me about Coder and pareview.

I changed the source code to fit the drupal coding standards.
Pareview throws 0 Errors and 5 Warnings, some line exceeds and comment stuff but i think
now the branch looks really good.

Here a list of thinks i have changed:

  • Deleted master branch.
  • Removed my name from the git link.
  • Updateded Description on Project Page.
  • Removed Branch "7.x-1.0" and added "7.x-1.x".
  • Removed "required" Attribute from Regioncode Form element.
  • Added locale as dependency.
  • Added a README.txt
  • Revised source code by Drupal coding standards.
  • Added new Tag "7.x-1.0".

To your ideas:

  • I think it's possible to alter tables. But I don't know if that's the best practice? I've got the feeling that this is the proper way.
  • I like the idea of the iso.inc file, maybe i include it in a future release.
  • Yes the standard language code is a iso code. And it's posible to add the region code to it for new languages. But you can't edit this field for existing languages and i also think it's better to have language and region divided.

Best regards
Michael

markpavlitski’s picture

Status: Needs review » Needs work

Your module is looking really good!

I would agree that providing your own table in this case is a better approach to altering tables provided by other modules.

I just have a few suggestions:

Firstly, your git link in the project description is pointing to the old 7.x-1.0 branch. I would suggest changing it to the public http link too:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/michaelpetri/1965464.git language_region

language_region.module:92: You should use array() as the default value for $cache, i.e.

  $cache = &drupal_static(__FUNCTION__, array(), $reset);

language_region.module:102: You should add an else statement here and set $cache[$langcode] to FALSE (or you can set it to NULL and change !isset() to !array_key_exists() on line 94). Otherwise the db_select() call can happen multiple times if the entry doesn't exist in the table.

You have a few comment and spacing issues too which are worth correcting. Take a look at the coding standards around indenting and the documentation standards and the automated test output for your module:
http://ventral.org/pareview/httpgitdrupalorgsandboxmichaelpetri1965464git

michaelpetri’s picture

Thanks for your kind feedback. I will start to fix everything later this week.

Best regards
Michael

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

I'm a robot and this is an automated message from Project Applications Scraper.

PA robot’s picture

Issue summary: View changes

Updated Project description.
Removes username from git link.