Ticket #7627 (closed Bug: fixed)

Opened 6 years ago

Last modified 13 months ago

multiselection.pt -> mode="view" not i18nized

Reported by: toutpt Owned by: toutpt
Priority: minor Milestone: 4.x
Component: Internationalization Version: 4.1
Keywords: Cc:

Description

(Moved from  http://dev.plone.org/archetypes/ticket/762)

Version of archetypes 1.5.4

ON a simple vocab, i18n is well on edit but display keys in mode view Take a look at template:

    <metal:view_macro define-macro="view"
                      tal:define="vocab python:field.Vocabulary(here);
                                  value python:accessor();
                                  display python:context.displayValue(vocab, value);"
                      tal:replace="structure display" />

displayValue.py do sth like this:

return vocab.getValue(context.unicodeEncode(value),
                      context.unicodeEncode(value))

So the text is not i18nized.

My proposal:

    <metal:view_macro define-macro="view"
                      tal:define="vocab python:field.Vocabulary(here);
                                  value python:accessor();
                                  display python:context.displayValue(vocab, value);"
                      >
      <ul>
        <li tal:repeat="item value"
                tal:content="python:vocab.getValue(item)"
                i18n:translate="" >
        </li>
      </ul>
    </metal:view_macro>

Thx

Attachments

i18n_view_multiselect.diff Download (1.0 KB) - added by dbfrombrc 5 years ago.
multiselect view mode i18n diff

Change History

comment:1 Changed 6 years ago by davethewebb

  • Reporter changed from davethewebb to toutpt

comment:2 Changed 6 years ago by wichert

  • Owner set to hannosch
  • Component changed from Archetypes to Internationalization

comment:3 Changed 6 years ago by hannosch

  • Milestone set to 3.0.x

comment:4 Changed 5 years ago by hannosch

  • Owner hannosch deleted

comment:5 Changed 5 years ago by vincentfretin

  • Keywords newbie TuneUp added

The problem still exist in Archetypes 1.5.11 (Plone 3.2.3) and Plone 4 (Archetypes 1.6dev) You have the problem in skins/archetypes/widgets/selection.pt, skins/archetypes/widgets/multiselection.pt, and skins/archetypes/widgets/languagewidget.pt

Indeed the problem can be resolved by adding i18n:translate=""

Jean-Michel, you don't have plone access now to commit the fix in branch 1.5, 1.6 and trunk for the 3 templates?

comment:6 Changed 5 years ago by dbfrombrc

  • Owner set to dbfrombrc
  • Status changed from new to assigned

comment:7 Changed 5 years ago by dbfrombrc

  • Owner changed from dbfrombrc to vincentfretin
  • Status changed from assigned to new

Please give me more detail as to how I might be able to reproduce this problem. I'm not sure how one is able to get a MultiSelectionWidget to display in view mode, perhaps I am missing something?

I've implemented the fix described above and want to test my changes before I check the code in. I cannot test that my changes to the page templates are working properly unless I can get a MultiSelectionWidget to display in view mode, if I understand the issue correctly. This I have been attempting to no avail. Please help!

comment:8 Changed 5 years ago by toutpt

This is an old bug but I will try to remember.

I have done a simple content types where I was wanting to display a LinesField with an i18nized vocab and the widget was multiselection.pt.

As usual I have define a custom view template:  http://plone.org/documentation/tutorial/customizing-at-view-templates/total-control-the-view-template

So you can get the field you want and call it's display mode

<tal:block define="mode string:view; field python:here.Schema().getField('mylinesfield');"
              <div class="my-custom-at-field">
                <metal:use_field use-macro="here/widgets/field/macros/view" />
              </div>
</tal:block>

Let me know If you still failed to reproduce I will provide a doctest.

comment:9 Changed 5 years ago by vincentfretin

  • Owner changed from vincentfretin to dbfrombrc

dbfrombrc, can you test and commit?

comment:10 Changed 5 years ago by jluvsu2

  • Keywords TuneUp20 added; TuneUp removed

comment:11 Changed 5 years ago by dbfrombrc

I've fixed this ticket but for some reason can't commit to svn. I've attached the diff for future reference.

Changed 5 years ago by dbfrombrc

multiselect view mode i18n diff

comment:12 Changed 5 years ago by jluvsu2

  • Keywords TuneUp21 added; TuneUp20 removed

comment:13 Changed 5 years ago by jluvsu2

  • Keywords TuneUp22 added; TuneUp21 removed

comment:14 Changed 5 years ago by toutpt

  • Keywords sprinti18n20091013 added
  • Owner changed from dbfrombrc to toutpt

comment:15 Changed 4 years ago by jluvsu2

  • Keywords TuneUp23 added; TuneUp22 removed

comment:16 Changed 4 years ago by jluvsu2

  • Keywords TuneUp24 added; TuneUp23 removed

comment:17 Changed 4 years ago by jluvsu2

  • Keywords TuneUp25 added; TuneUp24 removed

comment:18 Changed 4 years ago by jluvsu2

  • Keywords TuneUp26 added; TuneUp25 removed

comment:19 Changed 4 years ago by jluvsu2

  • Keywords TuneUp27 added; TuneUp26 removed

comment:20 Changed 4 years ago by jessilfp

  • Keywords TuneUp28 added; TuneUp27 removed

comment:21 Changed 4 years ago by jessilfp

  • Keywords TuneUp29 added; TuneUp28 removed

comment:22 Changed 4 years ago by jessilfp

  • Keywords TuneUp30 added; TuneUp29 removed

comment:23 Changed 4 years ago by vincentfretin

  • Keywords newbie TuneUp30 sprinti18n20091013 removed

comment:24 Changed 4 years ago by vincentfretin

The real fix is to patch Products.Archetypes/Products/Archetypes/skins/archetypes/displayValue.py

so instead of:

        return ', '.join([vocab.getValue(context.unicodeEncode(v),
                                         context.unicodeEncode(v)) \
                          for v in value if v])

it does:

from zope.i18n import translate

        return ', '.join([translate(vocab.getValue(context.unicodeEncode(v),
                                         context.unicodeEncode(v)), context=context.REQUEST) \
                          for v in value if v])

but I don't think we can import translate from zope.i18n in a Python Script...

comment:25 Changed 2 years ago by toutpt

  • Status changed from new to confirmed
  • Version set to 4.1
  • Milestone changed from 3.3.x to 4.x

comment:26 Changed 13 months ago by kiorky

just commited fixes (testcase on cmfplone & implementation in products.archetypes).

comment:27 Changed 13 months ago by kiorky

  • Status changed from confirmed to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.