From 76db374e156bc362782658ffaaada2140fd86417 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Claes=20Gyllensv=C3=A4rd?= <letharion@gmail.com>
Date: Mon, 12 Mar 2012 18:07:49 +0100
Subject: [PATCH] Adding condition for checking current language

---
 modules/locale.eval.inc  |   21 +++++++++++++++++++++
 modules/locale.rules.inc |   40 ++++++++++++++++++++++++++++++++++++++++
 rules.rules.inc          |    2 +-
 3 files changed, 62 insertions(+), 1 deletions(-)
 create mode 100644 modules/locale.eval.inc
 create mode 100644 modules/locale.rules.inc

diff --git a/modules/locale.eval.inc b/modules/locale.eval.inc
new file mode 100644
index 0000000..364a218
--- /dev/null
+++ b/modules/locale.eval.inc
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * @file
+ * Contains rules integration for the locale module needed during evaluation.
+ *
+ * @addtogroup rules
+ * @{
+ */
+
+/**
+ * Condition: Check if the node is published
+ */
+function rules_condition_language_is($required_language) {
+  global $language;
+  return $language->language == $required_language;
+}
+
+/**
+ * @}
+ */
diff --git a/modules/locale.rules.inc b/modules/locale.rules.inc
new file mode 100644
index 0000000..dd8dfe3
--- /dev/null
+++ b/modules/locale.rules.inc
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * @file
+ * Rules integration for the locale module.
+ *
+ * @addtogroup rules
+ * @{
+ */
+
+/**
+ * Implements hook_rules_file_info().
+ * On behalf of the locale module.
+ */
+function rules_locale_file_info() {
+  return array('modules/locale.eval');
+}
+
+/**
+ * Implements hook_rules_condition_info().
+ * On behalf of the locale module.
+ */
+function rules_locale_condition_info() {
+  $items['language_is'] = array(
+    'label' => t('Current interface language is'),
+    'base' => 'rules_condition_language_is',
+    'parameter' => array(
+      'language' => array(
+        'type' => 'text',
+        'label' => 'Enter the token that will be compared against the current interface language.',
+      ),
+    ),
+    'group' => t('Locale'),
+  );
+  return $items;
+}
+
+/**
+ * @}
+ */
diff --git a/rules.rules.inc b/rules.rules.inc
index 120773d..4bf0b22 100644
--- a/rules.rules.inc
+++ b/rules.rules.inc
@@ -21,7 +21,7 @@ foreach (rules_core_modules() as $module) {
  * for providing some general stuff.
  */
 function rules_core_modules() {
-  $return = array('data', 'entity', 'node', 'system', 'user', 'rules_core');
+  $return = array('data', 'entity', 'node', 'system', 'user', 'rules_core', 'locale');
   foreach (array('comment', 'taxonomy', 'php', 'path') as $module) {
     if (module_exists($module)) {
       $return[] = $module;
-- 
1.7.3.4

