Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

Status: Needs review » Needs work

Sounds good. You can do that already with the latest entity api and the language properties (in site:), however I think it's important enough to justify a separate condition.

+++ b/modules/locale.rules.inc
@@ -0,0 +1,38 @@
+ * rules integration for the locale module

Should start capitalized and end with a trailing point.

+++ b/modules/locale.rules.inc
@@ -0,0 +1,38 @@
+    'label' => t('Current language is'),

As there might different UI and content languages, maybe should be clear here and say "Current interface language is".

+++ b/modules/locale.rules.inc
@@ -0,0 +1,38 @@
+      'language' => array('type' => 'text'),

Needs a label and should use 'token' as type.

+++ b/modules/locale.rules.inc
@@ -0,0 +1,38 @@
+    'group' => t('Locale'),
+    'access callback' => TRUE,

Just skip the access callback.

Letharion’s picture

Assigned: Unassigned » Letharion
Letharion’s picture

Status: Needs work » Needs review
FileSize
2.57 KB

Status: Needs review » Needs work

The last submitted patch, rules_language_condition_3.patch, failed testing.

Letharion’s picture

As far as I can tell, the test fail is about sending e-mails out, and unrelated to my patch?

ShadowMonster’s picture

It is already on dev or you going commit it soon? - I will be happy to see it in rules :)

mitchell’s picture

Status: Needs work » Needs review

Retesting.

ShadowMonster, it hasn't been committed to dev. If you would like to help, please review the patch and post your feedback or track down why that test has failed.

mitchell’s picture

Status: Needs review » Active

Issue to fix the broken test: #1540266: Fix broken simpletests.

interX’s picture

The patch seems to work for me, thanks

mitchell’s picture

Component: Provided Rules integration » Provided Module Integrations
Status: Active » Reviewed & tested by the community
klausi’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/modules/locale.eval.inc
@@ -0,0 +1,21 @@
+/**
+ * Condition: Check if the node is published
+ */
+function rules_condition_language_is($required_language) {

wrong comment?

+++ b/modules/locale.rules.inc
@@ -0,0 +1,40 @@
+/**
+ * Implements hook_rules_file_info().
+ * On behalf of the locale module.
+ */

There should be an empty line between the function short description and the additional description. Also elsewhere.

+++ b/modules/locale.rules.inc
@@ -0,0 +1,40 @@
+    'label' => t('Current interface language is'),

Label should be fixed according to fago's comment.

hansrossel’s picture

Component: Provided Module Integrations » Module Integrations

I think this has been fixed allready in #1422996: localization and i18n integration.
[update]: I did not read fago's comment #1 well 'You can do that already with the latest entity api and the language properties (in site:), however I think it's important enough to justify a separate condition.'.
So the method below is how you can do it with site:

In the current stable Rules 2.2 you can set a condition:

Data comparison
Parameter: Data to compare: [site:current-page:language], Data value: Dutch

there is available:
site:current-page:language, Interface language The language code of the current user interface language.
site:current-page:language-content, Content language The language code of the current content language.

yuseferi’s picture

Status: Needs work » Needs review

rules_language_condiation.patch queued for re-testing.

MURANJO’s picture

Issue summary: View changes

#12 worked perfectly for me. I did not install or patch anything. I only used rules and created different payment methods with different languages. Then I made them available depending of the language of current page.

Many thanks!!

Status: Needs review » Needs work

The last submitted patch, 3: rules_language_condition_3.patch, failed testing. View results

TR’s picture

Assigned: Letharion » Unassigned
Status: Needs work » Needs review
Issue tags: +Needs tests
FileSize
2 KB

The patch in #3 no longer applies, which is no surprise because it's so old.

Here's a re-roll against the current HEAD. Uploading so the test bot can look at it.

All the other core integrations have tests in rules.test, so this new condition should also.

TR’s picture

Again, with a few coding standards fixes.

TR’s picture

Version: 7.x-2.x-dev » 8.x-3.x-dev
Status: Needs review » Postponed

It's been 2 years since I re-rolled the patch, but no one has found this important enough to review or to contribute to.

D7 Rules is basically in maintenance-only mode right now, as D7 is nearing its end-of-life. So I'm moving this to the 8.x-3.x branch for consideration.

I'm still willing to consider this for D8/D9 Rules, but I'm not going to work on this myself. If you find this useful and want to see it in Rules or in a contributed module like D8RE, then what we need here is a patch for Rules 8.x-3.x along with some tests cases to prove these new features are working.

Postponing this issue until someone thinks it's worth spending time on.