From 9f136da5d7e0ba84be5fed53136e095efe4400fa Mon Sep 17 00:00:00 2001 From: Keith Mitchell Date: Fri, 2 Dec 2011 16:45:00 -0800 Subject: [PATCH] Fix i18n issue with 'ago' translations --- r2/r2/lib/app_globals.py | 5 +++-- r2/r2/lib/translation.py | 2 +- r2/r2/templates/comment.html | 2 +- r2/r2/templates/comment.htmllite | 2 +- r2/r2/templates/commentvisitsbox.html | 2 +- r2/r2/templates/useriphistory.html | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/r2/r2/lib/app_globals.py b/r2/r2/lib/app_globals.py index 75c10adf3..795a3bf91 100755 --- a/r2/r2/lib/app_globals.py +++ b/r2/r2/lib/app_globals.py @@ -177,9 +177,10 @@ class Globals(object): self.running_as_script = global_conf.get('running_as_script', False) # turn on for language support - if not hasattr(self, 'lang'): self.lang = 'en' + if not hasattr(self, 'lang'): + self.lang = 'en' self.languages, self.lang_name = \ - get_active_langs(default_lang= self.lang) + get_active_langs(default_lang=self.lang) all_languages = self.lang_name.keys() all_languages.sort() diff --git a/r2/r2/lib/translation.py b/r2/r2/lib/translation.py index e30a8c427..6ccf728e1 100644 --- a/r2/r2/lib/translation.py +++ b/r2/r2/lib/translation.py @@ -594,7 +594,7 @@ def get_active_langs(path = _i18n_path, default_lang = 'en'): trans_name = {} for lang in os.listdir(path): x = os.path.join(path, lang, 'LC_MESSAGES') - if os.path.exists(x) and os.path.isdir(x): + if os.path.isdir(x): name = Translator.get_name(lang) trans_name[lang] = name if Translator.is_enabled(lang) and Translator.in_use(lang): diff --git a/r2/r2/templates/comment.html b/r2/r2/templates/comment.html index bb5c96555..1d185773a 100644 --- a/r2/r2/templates/comment.html +++ b/r2/r2/templates/comment.html @@ -104,7 +104,7 @@ ${parent.collapsed()} %if show: ${unsafe(self.score(thing, likes = thing.likes))} %endif - ${thing_timestamp(thing, thing.timesince)} ${_("ago")} + ${_("%(when)s ago") % dict(when=thing_timestamp(thing, thing.timesince))} %if thing.editted: *  %endif diff --git a/r2/r2/templates/comment.htmllite b/r2/r2/templates/comment.htmllite index 324db90a8..3194aa688 100644 --- a/r2/r2/templates/comment.htmllite +++ b/r2/r2/templates/comment.htmllite @@ -43,7 +43,7 @@ %if thing.deleted: - ${_("[deleted]")} ${thing.timesince} ${_("ago")} + ${_("[deleted]")} ${_("%(when)s ago") % dict(when=thing.timesince)} %else: diff --git a/r2/r2/templates/commentvisitsbox.html b/r2/r2/templates/commentvisitsbox.html index d7fffa483..512f9767b 100644 --- a/r2/r2/templates/commentvisitsbox.html +++ b/r2/r2/templates/commentvisitsbox.html @@ -35,7 +35,7 @@ %endif /> %endfor diff --git a/r2/r2/templates/useriphistory.html b/r2/r2/templates/useriphistory.html index 5fed1c4ed..5983643c2 100644 --- a/r2/r2/templates/useriphistory.html +++ b/r2/r2/templates/useriphistory.html @@ -46,7 +46,7 @@ ${ip} ${location.get('country_name', '')} - ${timestamp(last_visit)} ${_('ago')} + ${_('%(when)s ago') % dict(when=timestamp(last_visit))} % endfor