Firesphere / silverstripe-newsmodule

Silverstripe 3 Newsmodule
BSD 2-Clause "Simplified" License
24 stars 10 forks source link

Translatable support for multilanguage websites. #10

Closed Firesphere closed 11 years ago

Firesphere commented 11 years ago

Translatable options should be fixed asap! Including a "duplicate" button, to duplicate to another language.

zaucker commented 11 years ago

Can't use it until translatable works ... :-(

Firesphere commented 11 years ago

I do have a prototype for multilanguage support, but it's too buggy to publish yet. I will probably somewhere next week finalise and complete the multilanguage support.

zaucker commented 11 years ago

Cool!

Thanks, Fritz

On Tue, 26 Mar 2013, Simon Erkelens wrote:

I do have a prototype for multilanguage support, but it's too buggy to publish yet. I will probably somewhere next week finalise and complete the multilanguage support.

Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch

Firesphere commented 11 years ago

Hi Zaucker.

I hope this latest push is something you can work with. It's not perfect, it has a few bugs I think, but as far as I can see, at least it works if you include the translatable module. That's the last bug I need to fix.

zaucker commented 11 years ago

The new version seems to at least not break the site and the translated versions of the NewsHolder page show up with the correct navbar entry under the correct URL.

I guess what's missing is a way to set the locale for the individual News pages. Currently, all news entries seem to show up under the original (default) language. Or am I missing something?

Thanks, Fritz

Firesphere commented 11 years ago

I might have missed something. Since you asked, I kinda rushed to make this initial implementation :)

zaucker commented 11 years ago

Which I appreciate ... :-) ... so I'll just keep reporting my experience ... as I don't quite understand SS enough to fix it (if it's really broken) and can't send a patch ...

Cheers, Fritz

Fritz Zaucker Oetiker+Partner AG Aarweg 15 CH-4600 Olten +41 62 775 9903

Am 27.03.2013 um 18:26 schrieb Simon Erkelens notifications@github.com:

I might have missed something. Since you asked, I kinda rushed to make this initial implementation :)

— Reply to this email directly or view it on GitHub.

Firesphere commented 11 years ago

I appreciate the feedback very much!

In your development/testing area, you can add the following to your mysite/_config.php

Director::set_environment_type('dev');

This pushes the site in development mode. It will make your site slower (but for a setup/testing environment, it's not a big issue), but it will also show you any errors that occur. If there's any file from my module that causes an error, you can copy-paste me the error so I know better where to look :)

Ofcourse, this line needs to be removed once the site is online for real :)

zaucker commented 11 years ago

On Wed, 27 Mar 2013, Simon Erkelens wrote:

I appreciate the feedback very much!

In your development/testing area, you can add the following to your mysite/_config.php Director::set_environment_type('dev'); This pushes the site in development mode. It will make your site slower (but for a setup/testing environment, it's not a big issue), but it will also show you any errors that occur. If there's any file from my module that causes an error, you can copy-paste me the error so I know better where to look :)

I have my site on dev mode ... it is not that your module creates any errors.

With Translatable installed, I can without problem create translations of the NewsHolder page. I'd expect, that e.g. the en_US page would show English news messages, the de_DE page German news messages, etc. If I open the "News-area", I can see in the News page description that a News entry has a Locale variable, but I can't see any way to set this from the CMS. And all News messages are displayed on the en_US page (which is the default message of my site).

Or is this supposed to work differently?

Fritz

Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch

Firesphere commented 11 years ago

My latest update should fix this, but since I have 3 projects running, it's, as said before, a bit a "ok push update" version. I'll have time to make a really good version of the translatable support next week. Being inbetween jobs isn't really ideal for working on modules ;) I'm working on it, but that's exactly why I call it an "Initial version" ;)

zaucker commented 11 years ago

I am getting the following errors now when trying to add a news entry:

Warning at framework/view/SSViewer.php line 144: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object (http://james.oetiker.ch/~flarm/3.0.5-2013-03-28/admin/news/News/EditForm/field/News/item/new)

zaucker commented 11 years ago

BTW, what version of SS are you using? My last test was with 3.0.5 and translatable installed with composer and the master version of SortableGridField and GridFieldBulkEditingTools installed manually (as I am not sure how to install them with composer).

Firesphere commented 11 years ago

I have my module working on version 3.0.1 up to version 3.1 3.0.5 should simply work.

zaucker commented 11 years ago

Just tried a new clean install and as soon as I add Translatable, it breaks. Could you post or mail me your _config.php and _ss_environment.php files for me to compare?

And perhaps a list of all modules you have installed (or just an ls of your top-level directory).

I just don't get what's going wrong here ...

Firesphere commented 11 years ago

I don't have a very complicated _config, no _ss_env for this development though. What PHP version are you running on? I have a gut feeling where this issue is coming from suddenly...

MySQLDatabase::set_connection_charset('utf8');

// Set the current theme. More themes can be downloaded from
// http://www.silverstripe.org/themes/
SSViewer::set_theme('rs-4-clean');
if (file_exists('FirePHPCore/fb.php')) {
    require_once('FirePHPCore/fb.php');
} else {
    require_once('./../FirePHPCore/fb.php');
}
fb::setEnabled(true);
// Set the site locale
i18n::set_locale('en_US');

Director::set_environment_type('dev');
// Enable nested URLs for this site (e.g. page/sub-page/)
if (class_exists('SiteTree')) SiteTree::enable_nested_urls();

Object::add_extension('SiteTree', 'Translatable');

Installed modules: modules

zaucker commented 11 years ago

Hi Simon,

thanks, this is indeed rather simple. The main difference I see to my installation is that I have Translatable enable for SiteConfig as well:

Object::add_extension('SiteConfig', 'Translatable');

And I don't have some of the modules you have and I also don't have FirePHP.

I'll try again with a new installation and without Translatable for SiteConfig. Although I can't really see why this should change something.

One more (somewhat desperate) idea: would you be willing to send me a tar or zip file of your site (without the DB data, of course)? With that I could verify that it works in my environment well and then start taking modules out until it breaks.

Thanks, Fritz

On Thu, 28 Mar 2013, Simon Erkelens wrote:

I don't have a very complicated _config, no _ss_env for this development though.

MySQLDatabase::set_connection_charset('utf8');

// Set the current theme. More themes can be downloaded from
// http://www.silverstripe.org/themes/
SSViewer::set_theme('rs-4-clean');
if (file_exists('FirePHPCore/fb.php')) {
   require_once('FirePHPCore/fb.php');
} else {
   require_once('./../FirePHPCore/fb.php');
}
fb::setEnabled(true);
// Set the site locale
i18n::set_locale('en_US');

Director::set_environment_type('dev');
// Enable nested URLs for this site (e.g. page/sub-page/)
if (class_exists('SiteTree')) SiteTree::enable_nested_urls();

Object::add_extension('SiteTree', 'Translatable');

Installed modules: modules

Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch

Firesphere commented 11 years ago

Sure, that would be no problem. What exactly are your requirements? What features you want? I think I can send you a quick put-together of your requirements easily.

Please contact me for this via e-mail, provided in the README.md

zaucker commented 11 years ago

I managed a (somewhat) working SS 3.0.5 installation with newsmodule and translatable in live mode. However, when I switch to dev mode, there is a brief Notice message displayed in a popup and opening a news item or the news overview in the CMS doesn't work anymore.

In live mode I found the following issues:

  1. code/decorators/NewsSiteConfigDecorator.php: the AutoArchive field should probably be a CheckboxField instead of a NumericField
  2. The locale of the news items are always shown to be en_US (or perhaps the default locale), although the database actually has the proper locale setting as selected when saving the item. This occurs both in the NewsItem table and the News Item editing view (in the locale drop down which changes back to en_US right after pressing the save button).
  3. The NewsHolder page always shows all news items rather only the news items of its locale.

I didn't manage to get a working setup with SS 3.1 Beta2, but seems to be a bug in the corresponding version of the Translatable module (installed with composer).

Firesphere commented 11 years ago

Hi,

Issue 1 is an "on the list", as the autoarchive is meant to be a "number of days". I need to explain this more I guess ;)

The rest, I'll look into it.

Firesphere commented 11 years ago

Fixed locale-issue. The notices are not important, in Dev, they are caused by translatable, but it should work none the less. Newsholder now only show it's own locales.

Translatable is still not entirely stable, but closing this issue in favor of smaller, more specific issues.