Translations in included Templates

1 view
Skip to first unread message

Andy Adiwidjaja

unread,
Sep 23, 2008, 3:01:11 PM9/23/08
to SilverStripe Development
Hi,

my first post here: My name is Andy Adiwidjaja, I am from Germany.

we had some issues with the issue #2584 (we tried to translate the
forum). I have a rather simple solution, provided as patch here:
http://open.silverstripe.com/ticket/2584 (patch on SSViewer.php on
trunk).

This patch works, it provides the _t(...) functions with the correct
namespace (template name). The code switches the namespace in front of
the included template and switches it back again. I had to move some
ereg_replace code around, hope I didn't break something else.

What I wanted to ask:
- My code breaks because of this line:
if(!isset($lang[$locale][$class])) i18n::include_by_class($class);
in Core.php / function _t()

Do you have a plan for translations in templates? Should the
namespace of templates also include the Classname so include_by_class
can work? I don't know whether an include_by_template could be
implemented.

- Is my approach valid? Can you use it? We need a solution for this
ticket soon... I used a object method callback, not really elegant (no
partials in PHP...).

Cheers,


Andy

Ingo Schommer

unread,
Sep 23, 2008, 4:48:53 PM9/23/08
to SilverStripe Development
Hey Andy, thanks for your patch, from what I can see! Please read our
guidelines for submitting patches at http://doc.silverstripe.com/doku.php?id=submitting-patches

> I had to move some ereg_replace code around, hope I didn't break something else.
We need to extend SSViewerTest test coverage to ensure this - would
you be willing to contribute here?

We'd like to see:
* PHPDoc class/method documentation
* Inline documentation for tricky stuff like added regexes
* Unit test coverage simulating nested templates with i18n (see
http://doc.silverstripe.com/doku.php?id=testing-guide)

I think we're ready to help out with getting this patch to release
quality, but first have to ensure its the right direction.
Sam is our SSViewer guru, perhaps he can review whats already there?
Did you check your patch against the warnings and notes which Sam put
in the ticket?



On Sep 23, 9:01 pm, Andy Adiwidjaja <adiwidj...@gmail.com> wrote:
> Hi,
>
> my first post here: My name is Andy Adiwidjaja, I am from Germany.
>
> we had some issues with the issue #2584 (we tried to translate the
> forum). I have a rather simple solution, provided as patch here:http://open.silverstripe.com/ticket/2584(patch on SSViewer.php on

Andy Adiwidjaja

unread,
Sep 25, 2008, 5:05:51 PM9/25/08
to SilverStripe Development
Hi,

On 23 Sep., 22:48, Ingo Schommer <ingo.schom...@gmail.com> wrote:
> Hey Andy, thanks for your patch, from what I can see! Please read our
> guidelines for submitting patches athttp://doc.silverstripe.com/doku.php?id=submitting-patches

Oh ok, I will correct my patch.

> > I had to move some ereg_replace code around, hope I didn't break something else.
>
> We need to extend SSViewerTest test coverage to ensure this - would
> you be willing to contribute here?

Yes, I have to familiarize myself with the testing framework (I'm a
python programmer most of the time).

> We'd like to see:
>  * PHPDoc class/method documentation
>  * Inline documentation for tricky stuff like added regexes
>  * Unit test coverage simulating nested templates with i18n (seehttp://doc.silverstripe.com/doku.php?id=testing-guide)

Ok.

> I think we're ready to help out with getting this patch to release
> quality, but first have to ensure its the right direction.

Yes, that was my question, too :-)

> Sam is our SSViewer guru, perhaps he can review whats already there?

That would be nice :-) I need an answer to the i18n::include_by_class
question.

> Did you check your patch against the warnings and notes which Sam put
> in the ticket?

I didn't change the logic like Sam describes in the ticket (inlining
parseTemplateContent instead of getTemplateContent). I tried that but
had some serious context trouble.

BTW: Is there any development going on the rewrite of SSViewer?

Cheers,


Andy
Reply all
Reply to author
Forward
0 new messages