e7d3224
From 312962b85e3f59117efbdb7d7faf7c1c4ff17f5d Mon Sep 17 00:00:00 2001
e7d3224
From: Pierre-Yves Chibon <pingou@pingoured.fr>
e7d3224
Date: Mon, 1 Dec 2014 11:19:45 +0100
e7d3224
Subject: [PATCH] Adjust messages_path to support having the locale files in
e7d3224
 /usr/share/locale
e7d3224
e7d3224
Linux distribution normally centralize their locale files in /usr/share/locale
e7d3224
as a central place.
e7d3224
With this commit we check if the expected locale directory is present if so we
e7d3224
use it, otherwise we use /usr/share/locale.
e7d3224
e7d3224
This will allow packager of wtforms in Linux distribution to place the locale
e7d3224
files in the expected location in their distro
e7d3224
---
e7d3224
 wtforms/i18n.py | 5 ++++-
e7d3224
 1 file changed, 4 insertions(+), 1 deletion(-)
e7d3224
e7d3224
diff --git a/wtforms/i18n.py b/wtforms/i18n.py
e7d3224
index 3b45aa6..118e416 100644
e7d3224
--- a/wtforms/i18n.py
e7d3224
+++ b/wtforms/i18n.py
e7d3224
@@ -6,7 +6,10 @@ def messages_path():
e7d3224
     Determine the path to the 'messages' directory as best possible.
e7d3224
     """
e7d3224
     module_path = os.path.abspath(__file__)
e7d3224
-    return os.path.join(os.path.dirname(module_path), 'locale')
e7d3224
+    locale_path = os.path.join(os.path.dirname(module_path), 'locale')
e7d3224
+    if not os.path.exists(locale_path):
e7d3224
+        locale_path = '/usr/share/locale'
e7d3224
+    return locale_path
e7d3224
 
e7d3224
 
e7d3224
 def get_builtin_gnu_translations(languages=None):