This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Setup & design » Choosing language at publishing time
expandshrink

Choosing language at publishing time

Choosing language at publishing time

Monday 29 January 2007 12:40:58 pm - 7 replies

hello,

on fsfe.org we have been playing with ezp 3.8.6 to test the multilanguage features. We are stuck on a usability question: when users decide to create new content (say an article) the are brought to a 'select the language' page and then to the normal edit page. The default process looks something like:

create --> select language --> write content --> publish

We don't like the extra step and would prefer to select the language within the 'write content' phase. Would that be possible? and how?

thanks
stef

Tuesday 30 January 2007 4:01:45 pm

Hi Stefano,
I don't think that it's possible in a easy way.
Usually you have to choose the language first because the CMS engine create a draft using the choosen language.
Enable the debug redirection to see how it works.

Maybe you could skip the language question and use the default language for the site.
See
http://ez.no/community/forum/setu...content_creation_in_the_frontend_3_8

Regards,
Daniele

Tuesday 30 January 2007 9:53:04 pm

Try to add this

<input type="hidden" name="ContentLanguageCode" value="{ezini('RegionalSettings', 'Locale')}" />

in your form

Thursday 01 February 2007 7:09:14 pm

Thanks for the suggestions, but neither of the two really suits our needs because there can be cases where the user is using the Italian siteaccess but wants to write an article in English (or viceversa), so forcing a default language defeats the whole purpose of having a multilanguage site.

I have to say that this is quite disappointing. I don't see a simple way out since, as Daniele say, eZP creates a draft as soon as you hit the 'create' button.

Is there a way to change the language *after* the object has been published (or after the draft has been created)?

thanks
stef

PS are we the only one that think this is a serious usability issue?

Thursday 01 February 2007 11:34:31 pm

Hi,

Creating the draft as the first step is more a pain and has quite a lot of added problem (not to mention the effect on the speed before seeing the form blunk.gif Emoticon

Would it be a solution for your problem to offer 2 buttons create english and create italian ? (or offer a select with all the languages, or a drop menu or...)

X+

Friday 02 February 2007 7:17:16 am

> Would it be a solution for your problem to offer 2 buttons create english and
> create italian ? (or offer a select with all the languages, or a drop menu or...)

This could be a solution. I'll investigate this as a possibility.

Thanks,
stefano

Sunday 17 June 2007 1:49:57 pm

You can add this code ( taken from the admin/.../children.tpl template ) next to the 'New Topic' etc. buttons.

{* Language Selector  *}

{def $can_create_languages=fetch( content, prioritized_languages )}

    {if ne( $can_create_languages|count, 1 )}
    <script type="text/javascript">
    <!--
        {literal}
        function updateLanguageSelector( classSelector )
        {
            languageSelector = classSelector.form.ContentLanguageCode;
            if ( !languageSelector )
            {
                return;
            }

            classID = classSelector.value;
            languages = languagesByClassID[classID];
            candidateIndex = -1;

            for ( var index = 0; index < languageSelector.options.length; index++ )
            {
                var value = languageSelector.options[index].value;
                var disabled = true;

                for ( var indexj = 0; indexj < languages.length; indexj ++ )
                {
                    if ( languages[indexj] == value )
                    {
                        disabled = false;
                        break;
                    }
                }

                if ( !disabled && candidateIndex == -1 )
                {
                    candidateIndex = index;
                }

                languageSelector.options[index].disabled = disabled;
                if ( disabled )
                {
                    languageSelector.options[index].style.color = '#888888';
                    if ( languageSelector.options[index].text.substring( 0, 1 ) != '(' )
                    {
                        languageSelector.options[index].text = '(' + languageSelector.options[index].text + ')';
                    }
                }
                else
                {
                    languageSelector.options[index].style.color = '#000000';
                    if ( languageSelector.options[index].text.substring( 0, 1 ) == '(' )
                    {
                        languageSelector.options[index].text = languageSelector.options[index].text.substring( 1, languageSelector.options[index].text.length - 1 );
                    }
                }
            }

            if ( languageSelector.options[languageSelector.selectedIndex].disabled )
            {
                window.languageSelectorIndex = candidateIndex;
                languageSelector.selectedIndex = candidateIndex;
            }
        }

        function checkLanguageSelector( languageSelector )
        {
            if ( languageSelector.options[languageSelector.selectedIndex].disabled )
            {
                languageSelector.selectedIndex = window.languageSelectorIndex;
                return;
            }
            window.languageSelectorIndex = languageSelector.selectedIndex;
        }

        window.onload = function() { updateLanguageSelector( document.getElementById( 'ClassID' ) ); }
        {/literal}

        languagesByClassID = new Array();
        {foreach $can_create_classes as $class}
        languagesByClassID[{$class.id}] = [ {foreach $class.can_instantiate_languages as $tmp_language}'{$tmp_language}'{delimiter}, {/delimiter} {/foreach} ];
    {/foreach}
    // -->
    </script>
    {/if}

    

    {if and(eq( $can_create_languages|count, 1 ), is_set( $can_create_languages[0] ) )}
        <input name="ContentLanguageCode" value="{$can_create_languages[0].locale}" type="hidden" />
    {else}
        <select name="ContentLanguageCode" onchange="checkLanguageSelector(this)" title="{'Use this menu to select the language you wish use for the creation and click the "Create here" button. The item will be created within the current location.'|i18n( 'design/admin/node/view/full' )|wash()}">
            {foreach $can_create_languages as $tmp_language}
                <option value="{$tmp_language.locale|wash()}">{$tmp_language.name|wash()}</option>
            {/foreach}
       </select>
    {/if}
    {undef $can_create_languages}


{* /Language Selector  *}

 

Modified on Sunday 17 June 2007 2:00:01 pm by Luc Chase

Thursday 23 August 2007 3:41:26 pm

Thanks for the suggestion. We have put online a suitable solution.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from