Page 1 of 2

[SOLVED]babel language entry - syntax question

Posted: Sun Nov 29, 2009 6:24 pm
by pigsound
hi,
i'm setting up a multilingual site and am using "babel" for it. there i have the possibility to define a preset language entry for texts that occur in every language with the tag

Code: Select all

{babel show="welcome text"}
which is a very cool, time sparing method, i think. but i have one problem: when i want to change the text for my breadcrumbs:

Code: Select all

{breadcrumbs text='You are here' root='Home' delimiter='»'}
into

Code: Select all

{breadcrumbs text='{babel show="breadcrumbstext"}' root='Home' delimiter='»'}
it results in a distorted rest of that codeline, instead of "You are here" or "Sie sind hier".

is there a way to work around this problem, or did i make a mistake somewhere?

Re: babel language entry - syntax question

Posted: Sun Nov 29, 2009 9:04 pm
by Sonya
You cannot use {babel...} this way. It is not a variable, but plugin. Capture the output of the plugin and save it to the variable for usage in other tags. E. g.:

Code: Select all

{capture assign=welcome}
{babel show="welcome text"}
{/capture}
{breadcrumbs text=$welcome root='Home' delimiter='»'}

Re: babel language entry - syntax question

Posted: Mon Nov 30, 2009 2:17 pm
by pigsound
strange, doesn't work. i entered in the template

Code: Select all

{capture assign=brotcrumbtext}
{babel show="breadcrumbtext"}
{/capture}
{breadcrumbs starttext=$brotcrumbtext root='Home' delimiter='»'}
but now the only thing that shows on the page is a colon and the actual page name. so the "breadcrumbtext" obviously is ommitted for any reason. did i leave out some quotes (" " or ' '), or what is my mistake?

Re: babel language entry - syntax question

Posted: Wed Dec 02, 2009 2:49 pm
by pigsound
any clue anybody?  ???

Re: babel language entry - syntax question

Posted: Wed Dec 02, 2009 4:48 pm
by Sonya
pigsound wrote: any clue anybody?  ???
I have tested your code. It works on my installation. Are you sure you have created a language entry with the key breadcrumbtext? Are you sure the entry is not empty for the language?

Re: babel language entry - syntax question

Posted: Sun Dec 06, 2009 4:28 pm
by void
you could try this:

{capture assign=brotcrumbtext}{babel show="breadcrumbtext"}{/capture}
{breadcrumbs starttext="$brotcrumbtext" root='Home' delimiter='»'}

Re: babel language entry - syntax question

Posted: Sun Dec 06, 2009 5:02 pm
by pigsound
thanks for your effort, but that doesn't work as well. it just shows the ":" without the language text before. i also tried to create a new language entry after the suggestion i might have made a mistake here, but this had no effect.
i also wonder, what this command line means - is it caused by a mistaken php-code?

Code: Select all

Array
(
    [entrykey] => 1
    [action] => editentry
)
which is placed on the babel language entry page (see attached img)

Re: babel language entry - syntax question

Posted: Mon Dec 07, 2009 12:41 pm
by plger
Hi people,
pigsound wrote: i also wonder, what this command line means - is it caused by a mistaken php-code?
That's a debug portion of the code that just displays parameters and has no incidence on the way the module works... but thanks for pointing it out, obviously I forgot to hide that in the last release.

As to your problem, like Sonya I can't see why it isn't working... Just to make sure, when you try to display the text with {babel show="breadcrumbtext"}, does it display correctly?


Just a small note: Babel's default action has an assign parameter, so

Code: Select all

{capture assign=welcome}
{babel show="welcome text"}
{/capture}
can also be done with:

Code: Select all

{babel show="welcome text" assign="welcome"}
Pierre-Luc

Re: babel language entry - syntax question

Posted: Mon Dec 07, 2009 1:23 pm
by pigsound
hi pierre-luc,
As to your problem, like Sonya I can't see why it isn't working... Just to make sure, when you try to display the text with {babel show="breadcrumbtext"}, does it display correctly?
no, it does not show anything.


what information do you need to diagnose my problem? the template maybe? or the system settings?

----------------------------------------------

Cms Version: 1.6.1

Installed Modules:

   * CMSMailer: 1.73.14
   * FileManager: 1.0
   * MenuManager: 1.6.1
   * ModuleManager: 1.3.1
   * News: 2.10.1
   * nuSOAP: 1.0.1
   * Printing: 1.0
   * Search: 1.6.1
   * ThemeManager: 1.1.1
   * TinyMCE: 2.5.1
   * FormBrowser: 0.2.3
   * FormBuilder: 0.5.12
   * Gallery: 1.1
   * babel: 0.3.4


Config Information:

   * php_memory_limit:
   * process_whole_template: false
   * max_upload_size: 16000000
   * default_upload_permission: 664
   * assume_mod_rewrite: false
   * page_extension:
   * internal_pretty_urls: false
   * use_hierarchy: true


Php Information:

   * phpversion: 5.2.1
   * md5_function: An (Ja)
   * gd_version: 2
   * tempnam_function: An (Ja)
   * magic_quotes_runtime: Aus (Nein)
   * memory_limit: 32M
   * max_execution_time: 90
   * safe_mode: Aus (Nein)
   * session_save_path: /tmp (1777)


Server Information:

   * Server Api: apache2handler
   * Server Db Type: MySQL (mysql)
   * Server Db Version: 5.0.37


----------------------------------------------

Re: babel language entry - syntax question

Posted: Mon Dec 07, 2009 1:35 pm
by plger
Well it's a bug then.
I'll look into it.

Re: babel language entry - syntax question

Posted: Mon Dec 07, 2009 2:50 pm
by plger
The only way I'm able to reproduce this either is caused by the lack of a corresponding entry for this language or can be solved by adding {babel action="assign"} before calling the text.

Re: babel language entry - syntax question

Posted: Mon Dec 07, 2009 3:30 pm
by pigsound
hi pierre-luc,

that's it! following your advice, i entered the following code in my template - and now it works perfectly! thank you!

Code: Select all

{babel action="assign"}
{capture assign=welcome}
{babel show="welcome text"}
{/capture}
{breadcrumbs text=$welcome root='Home' delimiter='»'}

Re: babel language entry - syntax question

Posted: Mon Dec 07, 2009 4:01 pm
by Sonya
plger wrote: or can be solved by adding {babel action="assign"} before calling the text.
Pierre-Luc, can you explain this? In what case this line is required? Does it depend on server configuration or installed modules or version?

Thank you!

Re: [SOLVED]babel language entry - syntax question

Posted: Tue Dec 08, 2009 11:20 am
by plger
I wish I could ;)

The "assign" action is responsible for detecting the current page's language and assigning it to $page_lang and $page_lang_info. It should be triggered right before a page is compiled (it's registered with the ContentPreCompile event). But after using the module for a while, I found out that on some setups both variables seemed to be empty when used in the template. I first thought that the event wasn't triggered or I didn't use it correctly, so I tried manually adding {babel action="assign"} at the beginning of my templates. However, this did not solve all problems, and after some tests I realized that $page_lang was available at the beginning of the template, but not always at the end...
I remember reading somewhere that templates were processed in two parts (head and the rest) - if that's true, than maybe it's the source of the problem. In any case, I found out that if I called {babel action="assign"} just after the tag, I never had any problem with it...

Unfortunately, that's the best explanation I can offer. But I'd be glad if anybody could help with that issue, because calling the Hierarchy Manager (if you use the hierarchy method) twice isn't exactly optimal.

Pierre-Luc

Re: [SOLVED]babel language entry - syntax question

Posted: Tue Dec 08, 2009 1:55 pm
by Sonya
plger wrote: It should be triggered right before a page is compiled (it's registered with the ContentPreCompile event).
The event ContentPreCompile is called only if the page content is not cached. I have tested the event with UDT:

Code: Select all

echo '<h1>ContentPreCompile<h1>';
exit;
The UDT ist executed in 3 cases:
1. If the global cache is cleared.
2. If the page is defined as not cachable.
3. If the page content has been recently changed and not yet compiled.

If the page content (not the templates) is cached the event does not seem to be triggered.
plger wrote: But after using the module for a while, I found out that on some setups both variables seemed to be empty when used in the template. I first thought that the event wasn't triggered or I didn't use it correctly, so I tried manually adding {babel action="assign"} at the beginning of my templates. However, this did not solve all problems, and after some tests I realized that $page_lang was available at the beginning of the template, but not always at the end...
The variable $page_lang will not be recreated or reassigned until one of the 3 cases listed above occur on this page. Changing templates does not help, as the event ContentPreCompile is triggered only with the tag {content} and consider only changes made to the content part not the entire page. :(
plger wrote: I remember reading somewhere that templates were processed in two parts (head and the rest) - if that's true, than maybe it's the source of the problem.
It's true. See the config.php

Code: Select all

# In versions of CMS Made Simple prior to version 1.4, the page template was processed
# in it's entirety.  This behaviour was later changed to process the head portion of the
# page template after the body.  If you are working with a highly configured site that
# relies significantly on the old order of smarty processing, you may want to try
# setting this parameter to false.
$config['process_whole_template'] = false;
plger wrote: In any case, I found out that if I called {babel action="assign"} just after the tag, I never had any problem with it...
Because in this case you do not rely on the event and cache  ;)

Unfortunately, I have no solution. Normally you would add your UDT to the event TemplatePreCompile to catch template changes. But this event seems to be never triggered http://forum.cmsmadesimple.org/index.ph ... .msg182329