21288 Posts in 5733 Topics by 2602 members
| Go to End | Next > | |
| Author | Topic: | 2729 Views |
-
Re: Translatable custom data object?

24 December 2010 at 10:23pm
I believe I have the right stuff on my _config.php as I am able to translate pages and view the sitetree per language. I haven't added yet the language flags as I am trying to make this work in the back-end first.
I am testing code to implement this functionality right now:
Create ProjectPage's with a hasOne relationship to ProjectCountry.
ProjectCountry is a dataObject with 2 fields, name and countryCode.
And I want to create a couple of entries in the countryCode, translated both in English and Greek. Then when a user tries to add a ProductPage I want him to be able to select the corresponding ProjectCountry while viewing the list in his selected language.
Is this making sense to you?Thank you again.
-
Re: Translatable custom data object?

24 December 2010 at 10:33pm
That is great! My advice would be to focus entirely on a solution with pages right now - so complete what you have to the point that the website can operate in different languages.
As I said I cannot help with translation of dataobjects yet because I have only briefly looked at the module... that is why I advise using the stuff tried, tested and documented with pages right now
-
Re: Translatable custom data object?

24 December 2010 at 10:42pm
Thank you Barry, well I could not get it to work as I wanted using pages so I'll keep trying with translatableModelAdmin.
Have you implemented something like this in the past using Pages?
In any case thank you very much!Spyros
-
Re: Translatable custom data object?

24 December 2010 at 10:51pm
I have used translations to provide plain page translations. But I do need to start having dataobject translatable too - but not yet!
Please post back your solution when it's working I am very interested in this area.
-
Re: Translatable custom data object?

24 December 2010 at 11:53pm
I will post it since I haven't found any tutorial that accomplishes this and I suppose there are a lot of people interested.
-
Re: Translatable custom data object?

20 January 2011 at 11:42pm Last edited: 21 January 2011 8:44pm
Hi Spyrosk,
I'm in the same situation. The page translation is no problem with :
Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('SiteConfig', 'Translatable');
Translatable::set_allowed_locales( array('nl_NL', 'en_US', 'es_ES'));But the translations of the DataObject managed in ModelAdmin is much more difficult.
A possible solution is adding a field to your DataObjects called "Lang" or something like that. Make it a dropdown field with the available languages. In my case nl_NL, en_EN and es_ES. Everytime you create a new DataObject, you select what language it is.
In your template you can put this:
<% control ObjectByLang %>
<!-- whatever you want -->
<% end_control %>In your controller:
public function ObjectByLang() {
$currentReadingLocale = Translatable::get_current_locale();$MyObject= DataObject::get(
$callerClass = "classname",
$filter = "Lang = '$currentReadingLocale'",
$sort = "",
$join = "",
$limit = ""
);
return $MyObject;
}Only with this solution you have to create 3 different DataObject instead of one.
If you already have another solution, I'll hope you ost it back!
-
Re: Translatable custom data object?

11 February 2011 at 2:43am
Hi hammuh,
first of all I'm sorry I didn't reply for so long but I haven't really solved this. The workaround I used was to create two separate installations of SS on different directories, one for each language.
This means that now I have to edit the code twice for each change, but it is easier to edit content that doesn't apply to both languages, i.e. some data should only be visible to visitors from country X.
I will try your solution in the future where a 1 to 1 relationship (on translated content) is required.
Thank you very much for your help.
Spyros -
Re: Translatable custom data object?

14 February 2011 at 7:39pm
hey spyrosk,
you may have the same problem others (including me) have had.
this requires 2 patches, entered in bug tracker here-Chris
| 2729 Views | ||
| Go to Top | Next > |


