Blob Blame History Raw
From 312962b85e3f59117efbdb7d7faf7c1c4ff17f5d Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Mon, 1 Dec 2014 11:19:45 +0100
Subject: [PATCH] Adjust messages_path to support having the locale files in
 /usr/share/locale

Linux distribution normally centralize their locale files in /usr/share/locale
as a central place.
With this commit we check if the expected locale directory is present if so we
use it, otherwise we use /usr/share/locale.

This will allow packager of wtforms in Linux distribution to place the locale
files in the expected location in their distro
---
 wtforms/i18n.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/wtforms/i18n.py b/wtforms/i18n.py
index 3b45aa6..118e416 100644
--- a/wtforms/i18n.py
+++ b/wtforms/i18n.py
@@ -6,7 +6,10 @@ def messages_path():
     Determine the path to the 'messages' directory as best possible.
     """
     module_path = os.path.abspath(__file__)
-    return os.path.join(os.path.dirname(module_path), 'locale')
+    locale_path = os.path.join(os.path.dirname(module_path), 'locale')
+    if not os.path.exists(locale_path):
+        locale_path = '/usr/share/locale'
+    return locale_path
 
 
 def get_builtin_gnu_translations(languages=None):