Skip to content

Commit

Permalink
Making sure we use the existing locales and provide our languages pat…
Browse files Browse the repository at this point in the history
…ch to those used on homepage footer.
  • Loading branch information
rossjones committed Jan 16, 2012
1 parent 81faf51 commit 466e16b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 23 deletions.
23 changes: 4 additions & 19 deletions ckan/lib/helpers.py
Expand Up @@ -350,28 +350,13 @@ def resource_link(resource_dict, package_id):
'tl': u'Wikang Tagalog',
'ug': u'Uyƣurqə, ئۇيغۇرچە‎',
'wo': u'Wollof',
'cs_CZ': u'čeština, český jazyk',
'sr_Latn': u'српски језик',
}

def native_name_for_language_code(code):
def native_name_for_locale(code):
""" For the given language code make sure we return the name for that
language, in the language we were given. """
global language_patches
return Locale(code).get_display_name(code) or language_patches.get(code)

language_codes = []
ignore_language_codes = ['dv']
def language_codes_pairs(lang='en'):
""" Return an iterable of tuples which are (nativename, code,) for each
language """
global language_codes
global language_patches

if len(language_codes) == 0:
codes = [Locale(x) for x in babel.localedata.list() if len(x) == 2 and not x in ignore_language_codes]
for locale in codes:
if locale.display_name:
language_codes.append( (locale.display_name,locale.language))
elif locale.language in language_patches:
language_codes.append( (language_patches[locale.language],locale.language) )
return language_codes


2 changes: 1 addition & 1 deletion ckan/templates/layout_base.html
Expand Up @@ -193,7 +193,7 @@ <h3 class="widget-title">Languages</h3>
locale=str(locale),
return_to=current_url,
hash=current_url_hash)}">
${locale.display_name or locale.english_name}
${ locale.display_name or h.native_name_for_locale( str(locale)) }
</a>
</li>
</ul>
Expand Down
5 changes: 3 additions & 2 deletions ckan/templates/package/new_package_form.html
Expand Up @@ -168,8 +168,9 @@ <h3>Tags</h3>
<dt><label class="field_opt" for="language">Language</label></dt>
<dd>
<select id="language" name="language">
<py:for each="language_name, language_code in h.language_codes_pairs()">
<option value="${language_code}" py:attrs="{'selected': 'selected' if data.get('language', '') == language_code else None}" >${language_name}</option>
">
<py:for each="locale in h.get_available_locales()">
<option value="${str(locale)}" py:attrs="{'selected': 'selected' if data.get('language', '') == str(locale) else None}" >${locale.display_name or locale.english_name}</option>
</py:for>
</select>
</dd>
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/package/read_core.html
Expand Up @@ -77,7 +77,7 @@ <h3>Additional Information</h3>

<tr py:if="c.pkg.language">
<td class="dataset-label">Language</td>
<td class="dataset-details">${h.native_name_for_language_code(c.pkg.language)}</td>
<td class="dataset-details">${h.native_name_for_locale(c.pkg.language)}</td>
</tr>

<tr py:if="c.eu_country">
Expand Down

0 comments on commit 466e16b

Please sign in to comment.