Skip to content

Commit

Permalink
Org: Extend support for org_organisation_name
Browse files Browse the repository at this point in the history
L10n: fr enhancements
Minify
  • Loading branch information
flavour committed Dec 10, 2014
1 parent d464b46 commit 804651b
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 102 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ab3e431 (2014-12-10 15:52:10)
d464b46 (2014-12-10 19:17:23)
20 changes: 12 additions & 8 deletions languages/fr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,7 @@
'Electrical, gas, sewerage, water, hazmats': 'Electricité, gaz, eaux usées, eau, hazmats',
'Elevated': 'Élevée',
'Elevators': 'Ascenseurs',
'Email': 'le courrier électronique',
'Email': 'Courrier électronique',
'Email Address': 'Adresse électronique',
'Email address verified, however registration is still pending approval - please wait until confirmation received.': "Adresse électronique vérifié, toutefois d'enregistrement est toujours en attente d'approbation - veuillez patienter jusqu'à confirmation reçue.",
'Email Settings': "Paramètres d'addresse électronique",
Expand Down Expand Up @@ -3005,8 +3005,8 @@
'Names can be added in multiple languages': 'Les noms peuvent être ajoutés dans plusieurs langues',
'National': 'Nationale',
'National ID Card': "Carte Nationale d'Identité",
'National NGO': 'ONG nationale',
'National Staff': 'personnel National',
'National NGO': 'ONG Nationale',
'National Staff': 'Personnel National',
'Nationality': 'Nationalité',
'Nationality of the person.': 'Nationalité de la personne.',
'natural hazard': 'risques naturels',
Expand Down Expand Up @@ -3078,8 +3078,10 @@
'News': 'Nouvelles',
'Next': 'Suivante',
'next 100 rows': '100 lignes suivant',
'no': 'No',
'NO': 'No',
'NGO': 'ONG',
'NGO Office': 'Bureau ONG',
'no': 'non',
'NO': 'NON',
'No access at all': "Pas d'accès",
'No access to this record!': 'Aucun accès à cet enregistrement!',
'No action recommended': 'Aucune action recommandée',
Expand Down Expand Up @@ -3402,7 +3404,7 @@
'OR Reason': 'OU raison',
'OR Status': 'OU statut',
'OR Status Reason': "Raison d'OU statut",
'Organization': 'organization',
'Organization': 'Organisation',
'Organization added': 'Organisation ajouté',
'Organization deleted': 'Organisation supprimée',
'Organization Details': "Détails d'organisation",
Expand Down Expand Up @@ -4016,7 +4018,7 @@
'School used for other purpose': "L'école utilisée à d'autres fins",
'School/studying': "L'école/étudier",
'Schools': 'écoles',
'Search': 'search',
'Search': 'Recherche',
'Search & List Bin Types': 'Rechercher et lister types de bin',
'Search & List Bins': 'Recherche & liste BACS',
'Search & List Catalog': 'Rechercher et lister de catalogues',
Expand Down Expand Up @@ -4308,7 +4310,7 @@
'Setting deleted': 'Paramètre supprimé',
'Setting Details': 'Paramètre - Détails',
'Setting updated': 'Paramètre mis à jour',
'Settings': 'paramètres',
'Settings': 'Paramètres',
'Settings updated': 'Les paramètres mis à jour',
'Settings were reset because authenticating with Twitter failed': "Les paramètres ont été réinitialisé car l'authentification contre Twitter a échoué",
'Settings which can be configured through the web interface are available here.': "Les paramètres qui peuvent être configurées via l'interface Web sont disponibles ici.",
Expand Down Expand Up @@ -4982,6 +4984,8 @@
"Type the first few characters of one of the Person's names.": "Tapez les caractères des premières l'un des noms de la personne.",
'UID': 'uid',
'UN': 'ONU',
'UN Compound': 'Base des ONU',
'UN agency': "Agence de l'ONU",
'Un-Repairable': 'non réparables',
'unable to parse csv file': "Impossible d'analyser le fichier CSV",
'Unable to parse CSV file!': 'Impossible de traiter le fichier CSV!',
Expand Down
7 changes: 7 additions & 0 deletions modules/s3cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,13 @@ def get_L10n_name_alt_gis_location(self):
Whether to use Alternate Location names
"""
return self.L10n.get("name_alt_gis_location", False)

def get_L10n_translate_org_organisation(self):
"""
Whether to translate Organisation names/acronyms
"""
return self.L10n.get("translate_org_organisation", False)

def get_L10n_pootle_url(self):
""" URL for Pootle server """
return self.L10n.get("pootle_url", "http://pootle.sahanafoundation.org/")
Expand Down
87 changes: 76 additions & 11 deletions modules/s3db/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def model(self):
# CRUD strings
ADD_ORGANIZATION = T("Create Organization")
crud_strings[tablename] = Storage(
label_create = T("Create Organization"),
label_create = ADD_ORGANIZATION,
title_display = T("Organization Details"),
title_list = T("Organizations"),
title_update = T("Edit Organization"),
Expand Down Expand Up @@ -442,6 +442,11 @@ def model(self):
"comments",
]

if settings.get_L10n_translate_org_organisation():
text_fields.extend(("name.name_l10n",
"name.acronym_l10n"
))

if settings.get_org_branches():

# Additional text filter fields for branches
Expand Down Expand Up @@ -551,6 +556,10 @@ def model(self):
},
# Format for InlineComponent/filter_widget
org_group_membership = "organisation_id",
# Names
org_organisation_name = {"name": "name",
"joinby": "organisation_id",
},
# Sites
org_site = "organisation_id",
# Facilities
Expand Down Expand Up @@ -4394,7 +4403,6 @@ class org_OrganisationRepresent(S3Represent):
""" Representation of Organisations """

def __init__(self,
translate=False,
show_link=False,
parent=True,
acronym=True,
Expand All @@ -4404,22 +4412,32 @@ def __init__(self,

self.acronym = acronym

settings = current.deployment_settings
# Translation uses gis_location_name & not T()
translate = settings.get_L10n_translate_org_organisation()

if skip_dt_orderby:
# org/branch component which doesn't like the left join
self.skip_dt_orderby = True

if parent and current.deployment_settings.get_org_branches():
if parent and settings.get_org_branches():
# Need a custom lookup
self.parent = True
self.lookup_rows = self.custom_lookup_rows
fields = ["org_organisation.name",
"org_organisation.acronym",
"org_parent_organisation.name",
]
if translate:
fields += ["org_organisation.id",
"org_parent_organisation.id",
]
else:
# Can use standard lookup of fields
self.parent = False
fields = ["name", "acronym"]
if translate:
fields.append("id")

super(org_OrganisationRepresent,
self).__init__(lookup="org_organisation",
Expand Down Expand Up @@ -4459,6 +4477,7 @@ def custom_lookup_rows(self, key, values, fields=[]):
rows = db(query).select(otable.id,
otable.name,
otable.acronym,
ptable.id,
ptable.name,
left=left,
limitby=limitby)
Expand All @@ -4473,22 +4492,65 @@ def represent_row(self, row):
@param row: the org_organisation Row
"""

if self.parent:
# Custom Row (with the parent left-joined)
name = row["org_organisation.name"]
acronym = row["org_organisation.acronym"]
parent = row["org_parent_organisation.name"]
if self.translate:
language = current.session.s3.language
if language != current.deployment_settings.get_L10n_default_language():
table = current.s3db.org_organisation_name
query = (table.deleted == False) & \
(table.language == language)
if self.parent:
query &= (table.organisation_id.belongs((row["org_organisation.id"],
row["org_parent_organisation.id"])))
limitby = (0, 2)
else:
query &= (table.organisation_id == row.id)
limitby = (0, 1)
l10n = current.db(query).select(table.organisation_id,
table.name_l10n,
table.acronym_l10n,
limitby = limitby,
).as_dict(key="organisation_id")
if self.parent:
# Custom Row (with the parent left-joined)
org = l10n.get(row["org_organisation.id"])
if org:
name = org.get("name_l10n") or row["org_organisation.name"] or ""
acronym = org.get("acronym_l10n") or row["org_organisation.acronym"]
else:
name = row["org_organisation.name"] or ""
acronym = row["org_organisation.acronym"]
porg = l10n.get(row["org_parent_organisation.id"])
if porg:
parent = porg.get("name_l10n") or row["org_parent_organisation.name"]
else:
parent = row["org_parent_organisation.name"]
else:
# Standard row (from fields)
org = l10n.get(row.id)
if org:
name = org.get("name_l10n") or row["org_organisation.name"] or ""
acronym = org.get("acronym_l10n") or row["org_organisation.acronym"]
else:
name = row["org_organisation.name"] or ""
acronym = row["org_organisation.acronym"]
else:
# Standard row (from fields)
name = row["name"]
acronym = row["acronym"]
if self.parent:
# Custom Row (with the parent left-joined)
name = row["org_organisation.name"]
acronym = row["org_organisation.acronym"]
parent = row["org_parent_organisation.name"]
else:
# Standard row (from fields)
name = row["name"]
acronym = row["acronym"]

if not name:
return self.default
if self.acronym and acronym:
name = "%s (%s)" % (name, acronym)
if self.parent and parent:
name = "%s > %s" % (parent, name)

return s3_unicode(name)

# -------------------------------------------------------------------------
Expand Down Expand Up @@ -4869,6 +4931,9 @@ def org_rheader(r, tabs=[]):
if settings.get_org_resources_tab():
tabs.insert(-1, (T("Resources"), "resource"))

if settings.get_L10n_translate_org_organisation():
tabs.insert(1, (T("Local Names"), "name"))

# Use branches?
if settings.get_org_branches() and not skip_branches:
if settings.get_org_branches_tree_view():
Expand Down
13 changes: 13 additions & 0 deletions private/templates/Magnu/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
#settings.L10n.decimal_separator = "."
# Thousands separator for numbers (defaults to space)
#settings.L10n.thousands_separator = ","
# Uncomment this to Translate Organisation Names/Acronyms
settings.L10n.translate_org_organisation = True

# Security Policy
# http://eden.sahanafoundation.org/wiki/S3AAA#System-widePolicy
Expand Down Expand Up @@ -160,6 +162,17 @@
# Uncomment this to allow multiple site contacts per site (e.g. if needing a separate contact per sector)
settings.hrm.site_contact_unique = False

# -----------------------------------------------------------------------------
def customise_org_organisation_resource(r, tablename):

s3db = current.s3db
table = s3db[tablename]
list_fields = s3db.get_config(tablename, "list_fields")
list_fields.insert(2, (T("French Name"), "name.name_l10n"))
list_fields.insert(4, (T("French Acronym"), "name.acronym_l10n"))

settings.customise_org_organisation_resource = customise_org_organisation_resource

# -----------------------------------------------------------------------------
# Comment/uncomment modules here to disable/enable them
# Modules menu is defined in modules/eden/menu.py
Expand Down
2 changes: 2 additions & 0 deletions private/templates/default/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
#settings.L10n.translate_gis_location = True
# Uncomment this for Alternate Location Names
#settings.L10n.name_alt_gis_location = True
# Uncomment this to Translate Organisation Names/Acronyms
#settings.L10n.translate_org_organisation = True

# Finance settings
#settings.fin.currencies = {
Expand Down
Loading

0 comments on commit 804651b

Please sign in to comment.