Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba

translations for dataObjects


Go to End
Reply


2 Posts   1311 Views

Avatar
dacar

Community Member, 168 Posts

23 October 2009 at 11:55pm

hi,

for my site i want to show some articles on a article holder page. every article is saved as an dataobject to the db, not to the sitetree. the translation (i18n) for my sitetree elements works fine. But how can i use i18n for my dataobjects.

At the moment i have done the following but i think, that is not the right way?!

I have added a new object (transtable) to my _config.php: Object::add_extension('Dermatologie', 'Translatable');

After "dev/build" i got the new table "dermatologie_translationgroups". But i did not know to pass the values to it. So i decided to fill the new field "Locale" in "Dermatologie" with the language values used on the site:

function getCMSFields() {

		$array = array(
		  'de_DE' => 'deutsch',
		  'en_GB' => 'englisch',
		  'ru_RU' => 'russisch',
		  'fr_FR' => 'französisch',
		  'es_ES' => 'spanisch',
		);

		$fields = new FieldSet(
			new CheckboxField('anzeigen', 'Artikel ein-/ausblenden'),
			new CalendarDateField('gueltigab', 'Anzeigen ab dem'),
			new DropdownField(
				'Locale',
				'sprache wählen', 
				$array
			),
			new TextareaField('Headline', 'Überschrift'),
			new TextareaField('Subheadline', 'Subheadline'),
			new HtmlEditorField('Copytext', 'Artikeltext'),
			new ImageField('Thumb', 'Artikelbild')
		);

		return $fields;
	}

So i am able to give eache article a specific language.

Here are my questions:

1. How can i get the languages currently used in my Sitetree (translations) to pass them to my array. So it is more flexible in future.
2. I think this is the wrong way to solve this problem. How do you translate your dataobjects?
3. Does anybody know if there is a way tou use "/dev/tasks/i18nTextCollectorTask" without PHPUnit being installed on the Server (shared Hosting, CGI)?

I hope the will be a helpful discussion on item 2 ;-)

Greetings, Carsten.

Avatar
dacar

Community Member, 168 Posts

24 October 2009 at 3:23am

Hi,

i have found this article http://silverstripe.org/dataobjectmanager-module-forum/show/265720?start=16 and tried this patch http://open.silverstripe.org/ticket/4435.

The patch works fine. now you can pass the locale by URL. But the locale is not passed to my managed module. Is there a way to attach the locale to all links within the CMS? With this feature you could switch between the languages and have your language specific dataobjects.