Any plans to port this module to D7?

Comments

nonsie’s picture

Status: Active » Postponed

Plans - yes. However my current job does not include Drupal development so I'll either get to it at some point or someone will need to pay me to do it. Patches are always more than welcome;)

Barfly’s picture

I understand ^^
I'll try to figure out how to patch this module when i have more skills in drupal api

emilkarl’s picture

StatusFileSize
new11.84 KB

I've made a port that seems to work. Havent cleaned it up, anyone wanna review it?

nonsie’s picture

I'll take a look this weekend

dazz’s picture

i get the following notice when i enable the module.

Notice: Object of class DatabaseStatementBase could not be converted to int in domain_locale_install() (regel 34 van C:\wamp\www\drupal\sites\all\modules\contrib\domain_locale\domain_locale.install).

And when the module is enable the following message is always on top of every page

This form submits changes to your primary domain and may need to be entered from localhost.

I can select what languages should be enable for a domain but it doesn't seem to work. I'm not really sure what it is supposed to do, never used it on a D6 site but i keep getting all language in the language switcher or in the translation menu.
Maybe i'm just looking at this the wrong way but i thought it would be able to deactivated certain languages on different domains.

If i can help with something let me know.

agence web coheractio’s picture

Status: Postponed » Active

Hi,

I've fixed the install bug.
Just replace

$weight = $result + 1;

by

$record = $result->fetch();
$weight = $record->weight + 1;

in domain_locale.install

However, the module has no effect.
It seems that no hook gets triggered when viewing a node.
I am using domain 7.x-2.14.

Laurent

dqd’s picture

nonsie++

Thanks for this awesome contribution! Since I read that you have no time for that, I am willing to take over. I already brought up link module successfully to get ready for D7 release, awaited by 10+ users and I am willing to do the same here since I think this would be an awesome contribution to the Drupal community having i18n and Domain Access working fully together finally. Let me know what you think of it, if you still read this.

nonsie’s picture

I took a look at the D7 port a while back and it has more issues than posted in #5 and #6. I'd love to see a port posted before adding someone else to the mix.

make77’s picture

With the code included in the archive posted by emilkarl, we had all languages links in the language switcher block even though we didn't have enabled all of them for the current domain.

This fonction alters links to only display enabled languages on the current domain.


/**
 * Perform alterations on language switcher links.
 *
 * A language switcher link may need to point to a different path or use a
 * translated link text before going through l(), which will just handle the
 * path aliases.
 *
 * @param $links
 *   Nested array of links keyed by language code.
 * @param $type
 *   The language type the links will switch.
 * @param $path
 *   The current path.
 */
function domain_locale_language_switch_links_alter(array &$links, $type, $path) {
  global $_domain;
  $languages = domain_locale_lookup($_domain['domain_id']);
  $links = array_intersect_key($links, $languages);
}
make77’s picture

Furthermore, this function redirects a path with an unabled language for the current domain to the default language domain path.
(from patch provided in http://drupal.org/node/1316904)

/**
 * Implements hook_init().
 */
function domain_locale_init() {
  global $language, $_domain;
  $enabled_domain_langs = domain_locale_lookup($_domain['domain_id']);
  if ($enabled_domain_langs && !isset($enabled_domain_langs[$language->language])) { // if the user lang isnt supported
    $language_default = language_default(); // getting default lang
    if ($language_default) {
      $languages = language_list(); // get language list
      $language = $languages[$language_default->language]; // set the current language to the default language
      if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { // check if we are on a secure connection
        $http = 'https://';
      } else {
        $http = 'http://';
      }
      drupal_goto($http . $_domain['subdomain']);
    }
  }
}
rudiedirkx’s picture

The install bug is still a bug.

If you're doing

  $mod_i18n = db_query(.....
  if ($result) {
    $record = $result->fetch();
    $weight = $record->weight + 1;

the if is always true, because it's a DatabaseQuery object.

I've changed it to this:

  // Set domain_locale higher than i18n if it exists
  $mod_i18n = db_query("SELECT weight FROM {system} WHERE name = 'i18n'")->fetch();
  if ($mod_i18n) {
    $weight = $mod_i18n->weight + 1;
tararowell’s picture

Very interested to see how this port progresses. May even take a stab at it myself.
Subscribing

tararowell’s picture

I mashed up a D7 version of this module based on the posts in this thread. So far, the module works as expected with no errors.

nonsie, are you still planning to maintain this module if we come up with a decent D7 version? I would prefer that it be maintained by someone other than me since I am not thoroughly familiar with how it operates.

nonsie’s picture

I'm planning on getting back to this and other modules I maintain at the end of this week.

fernly’s picture

StatusFileSize
new16.59 KB

I also mashed up a D7 version of this module that seems to do what it's supposed to do (see attachment).

I had to make one more change to domain_locale.module:
Change the code in the function domain_locale_domainwarnings():

Old code:

function domain_locale_domainwarnings() {
	 return array(
		'locale_languages_overview_form'
	 );
}

New code:

function domain_locale_domainwarnings() {
	$forms =  array(
	    'locale_languages_overview_form' => 'admin/structure/domain/language/%domain_id'
	);
	return $forms;
}

I always got this warning on every page that I had to submit the form from the primary domain. This fixes the warning message.

PS: The code is not cleaned up, it just works.. (in my case)

fernly’s picture

Status: Active » Needs review
StatusFileSize
new16.59 KB

As I upgraded to Domain Access 7.x-3.1 and because the UI of DA has slightly changed, I also updated the Domain Locale module to be compatible with it. You can find it in the attachment.

Again, this is no official release of the module (at all). It's a non-reviewed port of the D6 version of Domain Locale (only for Domain Access 7.x-3.0 and higher!), but it does the trick for now.

If you're looking for a working version for Domain Access 7.x-2.x, you can try the solution in #15.

khaled.zaidan’s picture

Any news here?

fernly’s picture

If you are looking for a working D7 version, you can use #15 for Domain Access 7.x-2.x and #16 for Domain Access 7.x-3.x.

There is no official D7 release, yet.

fernly’s picture

Status: Needs review » Needs work

Apparently the D7 port is not working 100% yet.

Starting from #16, the following issue appears:

When the default language is set to english on a non-default domain, everything translates perfectly when switching to french (for example).
When french is set to default on the non-default domain, the website is only partly translated. For the moment I can't see a pattern. Some forms are translated, some are not. Even one menu item is translated, the others aren't.. Also Views pagers are translated, but the Views table headers and content aren't. And so on...

So when I use the language switcher in following cases I get these results:
English (default) => French = perfect translation
French (default) = partly translation
French (default) => English = perfect translation
English => French (default) = partly translation

The language prefix is always correct though.

When I set all languages (Drupal standard language form in Configuration, default domain language and subdomain language) I can possibly find to french, I still get the same results.

I'm wondering if the website would act the same without domain access, in that case it has nothing to do with domain_locale.

It's frustrating because everything works just fine starting from default language English...

Perhaps someone can point me in the right direction?

EDIT

Okay I figured it out:
When changing the default language for a subdomain from English to French, in the D7 multilingual system, the 'original text' of a translated string is labeled French under the hood (so now this 'French' original text, which was normally labeled English, has English content...) and an empty form field for an English translation appears. In the end, the French translation vanished untill the default language is set back to English.
Because I have no time at the moment to tune the domain_locale module, I'll add a quick fix in my case. If it works, I'll post it here.

Feel free to post a clean solution. I'm very curious how to fix this properly. Perhaps it's less difficult than I think it is?

fernly’s picture

Status: Needs work » Active

I solved the problem. If anyone is interested, this is how I've done it in short:

  • I created an extra helper module (didn't want to add it to the current D7 port) which does the following:
  • extending the domain locale languages form with an extra 'choose default language' form part and made sure the original default language selection is disabled so it stays English forever. This value is saved in an extra domain conf field.
  • creating an extra language negotiation method which takes this ' extra domain conf default language' in account. So the original 'domain conf default language' is left alone and can stay English.
  • now I just have to select this new language negotiation method and give it the heighest weight on this page: admin/config/regional/language/configure

If anyone has more questions about this, I'm willing to give more information about this solution.

As the D7 port is not yet there, I'll mark this issue as 'active'.

bb_dogg’s picture

lennartvv: would you mind posting you extra helper module as I'm very interested in your solution?

Also, do you have any idea on how to integrate this with the admin language module?

fernly’s picture

StatusFileSize
new4.07 KB

Hi bb_dogg,

You can find the helper module in the attachment. Read the README file.
I have one more feature to add to this module: selecting the available languages per domain (which language is visible to the end-user in the language switcher), as the original form to do this can not be used anymore (English always has to be selected now..).

So it's not 100% ready yet, but it selects the correct default language per domain. I also added a path prefix for English on this page: admin/config/regional/language/edit/en. By default, English has no path prefix.
I don't know if it's really necessary, but I did it anyway.

Don't forget to use the domain_locale version from post #16 together with this module.

Please let me know if it helped you out, or if it didn't do anything at all :-)

PS: The namings in the module are related to the company I work at.

benoit.pointet’s picture

Any progresses in this D7 port?

nonsie: you did not give any news since beginning of december, 6 months ago, is it time to look for a new maintainer (I see there are volunteers)?

lennartvv: are the d7 ports + extra modules you posted on #16 and #22 still actual or did you apply changes since then?

Cheers,
b.

fernly’s picture

Hi Benoit,

You can still use these modules. I haven't made any updates yet.

benoit.pointet’s picture

StatusFileSize
new14.57 KB

Thanks lennartvv.

I added a drush command to the domain_locale module:

domain-locale-set sub.example.com 'de fr' --default=fr

It obviously allows to set the locale settings for a domain thru drush.

Yuri’s picture

Hi, would it be possible to post this as a dev version on the project page?

Yuri’s picture

I installed the #16#22 module combination and it apparently works...to the extend that the language switcher block does not work any more, shows the wrong language.

Also, I have English and Dutch as languages, and when I disable English and set Dutch as default language, the site gives a redirect loop.

Yuri’s picture

By the way..the language field still allows selection of all languages, even after disabling some through the modules mentioned above.

The redirect loop is gone now (maybe clearing cache helped) but for some reason I can't disable the primary language that Drupal was installed with. Not sure if that is not supposed to be able with these modules. So basically for me English is always present even if I want only to show Dutch.

Yuri’s picture

Another bug: In views, when the title field has been selected as 'Link this field to the original piece of content' and with the modules mentioned above, the default language is set to something other than the primary language the site has been installed in, the view shows titles that result in 'page not found' errors. There is problem that the url prefix is used together with the title of the original language, which combination is not valid. So, the default language settings should also change this behavior in views.

camdarley’s picture

Title: D7 port » Domain Locale: D7 port
apemantus’s picture

Yuri,

Re some of your bugs:

"the language field still allows selection of all languages, even after disabling some through the modules mentioned above."

This is not part of the scope of Domain Locale at the moment (see #747318: All languages shown as available ) - you can fix it pretty easily using hook_form_alter although.

"I have English and Dutch as languages, and when I disable English and set Dutch as default language, the site gives a redirect loop."

Are you using something like Global Redirect? Previous versions of that played funny with i18n.

apemantus’s picture

lennartvv,

I've installed your helper module; the rationale behind it makes sense to me and I think something like this should be in the proposed D7 version. However, would it break if the original (default) site was not in English. It's possible (I think) to set up Drupal 7 so the default language is, say, French (and uninstall English)? Is that a valid assumption (I get slightly confused with D7 and i18n)? Can we replace references to "en" with _nebus_fetch_default_prefix() and have

function _nebus_fetch_default_prefix() {
  $language = language_default();
  return $language->language;
}

The other issue is I can't seem to remove English as a language for a domain, presumably as it's flagged as the default language in the radio button. Can we just remove $form['domain_language'][$lang_code]['site_default'] entirely from the form?

(One more thing is, there's also a "default language" setting on admin/structure/domain/view/$domain_id/config, which using the helper module is always English. Maybe for clarity this should either be removed or (preferably) overriden?)

apemantus’s picture

Ah, sorry, I get it. Was being slow. So your helper modules relies on English being selected and being seen by Drupal as the default language, while actually overruling it with a custom "default" language. So you can't unselect English by design. Nnngh. Not sure how what I want (English site in English, German Site in German, Swiss site in both) is going to work.

mac_weber’s picture

D7 port released. Thanks to emilkarl, lennartvv, Laurent_, make77 and others who contributed to make it possible.

@lennartvv I don't understand how nebus_domain_locale would help. I got it to work without this helper module. Please open a new issue if you think this helper module is a need and post is as a patch.

@benoit.pointet I did not include the drush commands for now. If you want you can open a new issue and I will give you credit. Please, post it as a patch.

mac_weber’s picture

Status: Active » Closed (fixed)