Skip to content

Commit

Permalink
[1650] Fixed native name for language to optionally take a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed May 1, 2012
1 parent c1d648c commit 4827743
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ckan/lib/helpers.py
Expand Up @@ -156,10 +156,14 @@ def lang():
''' Return the language code for the current locale eg `en` '''
return request.environ.get('CKAN_LANG')

def lang_native_name():
''' Return the langage name currently used in it's localised form '''
locale = get_locales_dict().get(lang())
return locale.display_name or locale.english_name
def lang_native_name(lang=None):
''' Return the langage name currently used in it's localised form
either from parameter or current environ setting'''
lang = lang or lang()
locale = get_locales_dict().get(lang)
if locale:
return locale.display_name or locale.english_name
return lang

class Message(object):
"""A message returned by ``Flash.pop_messages()``.
Expand Down

0 comments on commit 4827743

Please sign in to comment.