Download & Extend

Features support for languages

Project:Features
Version:7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:sprint candidate

Issue Summary

as follow up of #1083394: Meta issue: Features support for core component types added in D7

For a custom project I wrote some language implementation. Patch will come in first comment.

Comments

#1

Status:active» needs review

And there is the patch.

AttachmentSize
features-locale-1279938-1.patch 0 bytes

#2

Status:needs review» needs work

Your patch is empty :)

#3

Ok :D Finally it's here again ...

AttachmentSize
features-locale-1279938-3.patch 5.41 KB

#4

Status:needs work» needs review

#5

Tagging

#6

Status:needs review» needs work

I got this error when enabling a feature:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'plurals' at row 1: UPDATE {languages} SET plurals=:db_update_placeholder_0, formula=:db_update_placeholder_1 WHERE (language = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => [:db_update_placeholder_1] => [:db_condition_placeholder_0] => fi ) in _features_language_save() (line 138 of /www/sites/all/modules/contrib/features/includes/features.locale.inc).

Using

  • Drupal 7.8
  • features 7.x-1.0-beta4 with the patch #3
  • MySQL 5.1.41

#7

Status:needs work» needs review

+++ b/includes/features.locale.inc
@@ -0,0 +1,160 @@
+        'plurals' => empty($language->plurals) ? '' : $language->plurals,

The default value should probably be '0' instead of '', adding a new patch.

I didn't experience the error from #6 myself, but that's because I was testing a language which has plurals set to 2.

AttachmentSize
features-locale-1279938-7.patch 5.41 KB

#8

@helmo, I assume we even have to use 0 instead of '0'.

@apaatsio , could you review/test the patch again please? ;)

AttachmentSize
features-locale-1279938-8.patch 5.41 KB

#9

Status:needs review» reviewed & tested by the community

@derhasi: Yes, the 0 is better.

I think that this is ready...

#10

Status:reviewed & tested by the community» needs work

Minor coding standards issue; have you run the file through coder?

+++ b/includes/features.locale.inc
@@ -0,0 +1,160 @@
+      // Add language to exports

Missing .


+
+ // No pipe.
+ $pipe = array();
+ return $pipe;

This isn't against coding standards, but it just looks odd. I'd either put $pipe at the top, or return array();

+++ b/includes/features.locale.inc
@@ -0,0 +1,160 @@
+    if (array_key_exists($name, $language_list)) {

Not against coding standards again, but tmk array_key_exists is slower and not as useful as !empty($language_list[$name]); for example, $language_list could be array('blah' => '') and array key exist would return true, despite blah being ''.

+++ b/includes/features.locale.inc
@@ -0,0 +1,160 @@
+    // Rebuild locale javascript hashs.
+    //_locale_rebuild_js($language->language);

Commented out code? :(

+++ b/includes/features.locale.inc
@@ -0,0 +1,160 @@
\ No newline at end of file

New line!

#11

Status:needs work» needs review

Oh, sure coder ... and your are right with your other comments too ;)

I attached a cleaned up patch.

AttachmentSize
features-locale-1279938-11.patch 5.38 KB

#12

Status:needs review» reviewed & tested by the community

Great, still works as expected :)

#13

#8 works for me

#14

The patch in #11 applies cleanly and works as expected. Great work Johannes!

#15

+1 RTBC

I would like to find a hook to add some code after reverting/rebuilding a feature.
For example, it would be nice to run l10n_update after importing new languages.

I tried

<?php
/**
* Implements hook_enable().
*/
function my_feature_enable() {
 
l10n_update_modules_enabled(module_list());
}
?>

but it does not work :/

#16

Status:reviewed & tested by the community» fixed

Committed 1027e94

#17

Status:fixed» needs work

mpotter, it seems you forgot the include file :)

#18

Status:needs work» needs review

New patch with the remaining includes/features.locale.inc file.

AttachmentSize
features-locale-1279938-18.patch 4.54 KB

#19

Status:needs review» fixed

Ack. Just forgot to add the include file to git. Committed with include file f6ff815.

#20

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here