@@ -55,9 +55,11 @@ class Babel(object):
5555 })
5656
5757 def __init__ (self , app = None , default_locale = 'en' , default_timezone = 'UTC' ,
58- date_formats = None , configure_jinja = True ):
58+ default_domain = 'messages' , date_formats = None ,
59+ configure_jinja = True ):
5960 self ._default_locale = default_locale
6061 self ._default_timezone = default_timezone
62+ self ._default_domain = default_domain
6163 self ._date_formats = date_formats
6264 self ._configure_jinja = configure_jinja
6365 self .app = app
@@ -79,6 +81,7 @@ def init_app(self, app):
7981
8082 app .config .setdefault ('BABEL_DEFAULT_LOCALE' , self ._default_locale )
8183 app .config .setdefault ('BABEL_DEFAULT_TIMEZONE' , self ._default_timezone )
84+ app .config .setdefault ('BABEL_DOMAIN' , self ._default_domain )
8285 if self ._date_formats is None :
8386 self ._date_formats = self .default_date_formats .copy ()
8487
@@ -182,6 +185,12 @@ def default_timezone(self):
182185 """
183186 return timezone (self .app .config ['BABEL_DEFAULT_TIMEZONE' ])
184187
188+ @property
189+ def domain (self ):
190+ """The message domain for the translations as a string.
191+ """
192+ return self .app .config ['BABEL_DOMAIN' ]
193+
185194 @property
186195 def translation_directories (self ):
187196 directories = self .app .config .get (
@@ -213,7 +222,11 @@ def get_translations():
213222
214223 babel = current_app .extensions ['babel' ]
215224 for dirname in babel .translation_directories :
216- catalog = support .Translations .load (dirname , [get_locale ()])
225+ catalog = support .Translations .load (
226+ dirname ,
227+ [get_locale ()],
228+ babel .domain
229+ )
217230 translations .merge (catalog )
218231 # FIXME: Workaround for merge() being really, really stupid. It
219232 # does not copy _info, plural(), or any other instance variables
0 commit comments