Skip to content

Commit

Permalink
Merge pull request #36 from collective/localized-address-#29
Browse files Browse the repository at this point in the history
localize address (fixes #29)
  • Loading branch information
vincentfretin authored Jan 17, 2017
2 parents 035cfbb + ca5f589 commit 265fec0
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 72 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Changelog
1.11 (unreleased)
-----------------

- Change field order for address (`<street> <nr>` - as this is more common in most countries)

* address format can be localized by using msgid `address_line`
* field order in add and edit forms can be patched (see README for details)

(fixes #29) [fRiSi]

- Fixed indexing a held position which organization has been removed.
[thomasdesvenain]

Expand Down
18 changes: 18 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ Modify your directory to customize the organization types and the position types

Look at the test data profile collective.contact.core test data for detailed examples.

Localization
============

In some countries (ie. France) the format of an address is `<nr> <street>` instead of `<street> <nr>`.

You can provide a translation for the `address_line` i18n-msgid in the collective.contact.core translations if this is the case for your country.

You can also patch `collective.contact.core.behaviors.ADDRESS_FIELDS` to make the number field show up before the street in add and edit forms.

In your addon, create a `patches.py` file with this content::

from collective.contact.core import behaviors
behaviors.ADDRESS_FIELDS[0:2] = reversed(behaviors.ADDRESS_FIELDS[0:2])
behaviors.ADDRESS_FIELDS_PLUS_PARENT[2:4] = reversed(behaviors.ADDRESS_FIELDS_PLUS_PARENT[2:4])

and import it in yout `__init__.py` so the patches takes effect.


Installation
============

Expand Down
17 changes: 12 additions & 5 deletions src/collective/contact/core/behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,23 @@ class IGlobalPositioning(model.Schema):
alsoProvides(IGlobalPositioning, IFormFieldProvider)


ADDRESS_FIELDS = (
'number',
# must stay a list so it can be patched
ADDRESS_FIELDS = [
'street',
'number',
'additional_address_details',
'zip_code',
'city',
'region',
'country',
)
]


# must stay a list so it can be patched
ADDRESS_FIELDS_PLUS_PARENT = [
'use_parent_address',
'parent_address'] + ADDRESS_FIELDS


CONTACT_DETAILS_FIELDS = (
'phone',
Expand All @@ -128,8 +136,7 @@ class IContactDetails(model.Schema):
fieldset(
'address',
label=_(u'Address'),
fields=('use_parent_address',
'parent_address') + ADDRESS_FIELDS
fields=ADDRESS_FIELDS_PLUS_PARENT

)

Expand Down
6 changes: 3 additions & 3 deletions src/collective/contact/core/browser/templates/address.pt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
tal:repeat="address args">
<div tal:condition="address" class="field adr address">
<label><tal:block i18n:translate="">Address</tal:block>:</label>
<div class="street-address" class="address_line street-address">
<span i18n:translate="" tal:replace="address/number"></span>
<span i18n:translate="" tal:replace="address/street"></span>
<div class="street-address" class="address_line street-address" i18n:translate="address_line">
<span i18n:name="street" tal:replace="address/street"></span>
<span i18n:name="number" tal:replace="address/number"></span>
</div>
<div class="additional_address_details" class="address_line">
<span i18n:translate="" tal:replace="address/additional_address_details"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2016-09-29 10:34+0000\n"
"POT-Creation-Date: 2017-01-13 13:05+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -363,6 +363,11 @@ msgstr ""
msgid "Zip Code"
msgstr ""

#. Default: "${street} ${number}"
#: ../browser/templates/address.pt:9
msgid "address_line"
msgstr ""

#. Default: ":"
#: ../browser/basefields/templates/held_position.pt:7
#: ../browser/templates/organization.pt:55
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: collective.contact.core\n"
"POT-Creation-Date: 2016-09-29 10:34+0000\n"
"POT-Creation-Date: 2017-01-13 13:05+0000\n"
"PO-Revision-Date: 2016-11-16 11:24+0100\n"
"Last-Translator: Cédric Messiant <cedric.messiant@gmail.com>\n"
"Language-Team: French\n"
Expand Down Expand Up @@ -53,11 +53,13 @@ msgstr "Zusätzliches Feld"
msgid "Additional label with information that does not appear on position label"
msgstr "Zusätzliches Feld mit Information die nicht im Positionsfeld aufscheint"

#: ../behaviors.py:130 ../browser/templates/address.pt:6
#: ../behaviors.py:130
#: ../browser/templates/address.pt:6
msgid "Address"
msgstr "Adresse"

#: ../behaviors.py:320 ../browser/basefields/templates/person.pt:27
#: ../behaviors.py:320
#: ../browser/basefields/templates/person.pt:27
msgid "Birthday"
msgstr "Geburtstag"

Expand Down Expand Up @@ -85,7 +87,8 @@ msgstr "Kontaktdetails"
msgid "Country"
msgstr "Land"

#: ../browser/addcontact.py:63 ../browser/templates/organization.pt:83
#: ../browser/addcontact.py:63
#: ../browser/templates/organization.pt:83
#: ../browser/templates/position.pt:41
msgid "Create ${name}"
msgstr "Eingabe ${name}"
Expand All @@ -111,12 +114,14 @@ msgstr "Akademischen Titel bei Person anzeigen"
msgid "Download VCard"
msgstr "VCard herunterladen"

#: ../behaviors.py:137 ../browser/templates/contactdetails.pt:11
#: ../behaviors.py:137
#: ../browser/templates/contactdetails.pt:11
msgid "Email"
msgstr "Email"

#: ../browser/basefields/templates/held_position.pt:29
#: ../browser/templates/heldpositions.pt:47 ../content/held_position.py:44
#: ../browser/templates/heldpositions.pt:47
#: ../content/held_position.py:44
msgid "End date"
msgstr "Enddatum"

Expand Down Expand Up @@ -197,7 +202,8 @@ msgstr "Nicht zugewiesen"
msgid "Number"
msgstr "Nummer"

#: ../browser/addcontact.py:271 ../content/directory.py:37
#: ../browser/addcontact.py:271
#: ../content/directory.py:37
#: ../profiles/default/types/organization.xml
msgid "Organization"
msgstr "Organisation"
Expand All @@ -222,7 +228,8 @@ msgstr "Organisationstypen"
msgid "Organization/Position"
msgstr "Organisation/Position"

#: ../browser/templates/contact.pt:17 ../browser/templates/directory.pt:19
#: ../browser/templates/contact.pt:17
#: ../browser/templates/directory.pt:19
msgid "Organizations"
msgstr "Organisationen"

Expand All @@ -234,11 +241,13 @@ msgstr "Organisationen in dieser Organisation"
msgid "Other contacts in this organization:"
msgstr "Weitere Kontakte in dieser Organisation"

#: ../browser/templates/organization.pt:19 ../browser/templates/position.pt:17
#: ../browser/templates/organization.pt:19
#: ../browser/templates/position.pt:17
msgid "Parent organizations"
msgstr "Übergeordnete Organisationen"

#: ../browser/addcontact.py:277 ../profiles/default/types/person.xml
#: ../browser/addcontact.py:277
#: ../profiles/default/types/person.xml
#: ../upgrades/profiles/v2/types/person.xml
msgid "Person"
msgstr "Person"
Expand All @@ -259,7 +268,8 @@ msgstr "Telefon"
msgid "Phone number"
msgstr "Telefon"

#: ../content/held_position.py:48 ../content/person.py:52
#: ../content/held_position.py:48
#: ../content/person.py:52
msgid "Photo"
msgstr "Foto"

Expand Down Expand Up @@ -310,7 +320,8 @@ msgid "Select the position held by this person in the selected organization"
msgstr "Wähle die Position, die die Person in der gewählten Organisation hat"

#: ../browser/basefields/templates/held_position.pt:23
#: ../browser/templates/heldpositions.pt:42 ../content/held_position.py:40
#: ../browser/templates/heldpositions.pt:42
#: ../content/held_position.py:40
msgid "Start date"
msgstr "Beginndatum"

Expand Down Expand Up @@ -342,14 +353,20 @@ msgstr "Verwende Positionen zum Suchen von Personen"
msgid "Use the belonging entity address"
msgstr "Verwende dazugehörige Adresseinheit"

#: ../behaviors.py:159 ../browser/templates/contactdetails.pt:50
#: ../behaviors.py:159
#: ../browser/templates/contactdetails.pt:50
msgid "Website"
msgstr "Webseite"

#: ../behaviors.py:238
msgid "Zip Code"
msgstr "Postleitzahl"

#. Default: "${street} ${number}"
#: ../browser/templates/address.pt:9
msgid "address_line"
msgstr ""

#. Default: ":"
#: ../browser/basefields/templates/held_position.pt:7
#: ../browser/templates/organization.pt:55
Expand Down Expand Up @@ -382,3 +399,4 @@ msgstr "Organisation/Position"
#: ../browser/templates/organization.pt:65
msgid "to"
msgstr "bis"

3 changes: 2 additions & 1 deletion src/collective/contact/core/locales/de/LC_MESSAGES/plone.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: collective.contact.core\n"
"POT-Creation-Date: 2016-09-29 10:34+0000\n"
"POT-Creation-Date: 2017-01-13 13:05+0000\n"
"PO-Revision-Date: 2016-11-16 11:25+0100\n"
"Last-Translator: Cédric Messiant <cedricmessiant@ecreall.com>\n"
"Language-Team: Ecréall\n"
Expand Down Expand Up @@ -47,3 +47,4 @@ msgstr "Kein"
#: ../profiles/testing/types/testtype.xml
msgid "Test type"
msgstr "Test-Typ"

Loading

0 comments on commit 265fec0

Please sign in to comment.