[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Publisher/Browser - I18nResourceMeta.py:1.2
Marius Gedminas
mgedmin@delfi.lt
Tue, 25 Jun 2002 10:44:52 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Publisher/Browser
In directory cvs.zope.org:/tmp/cvs-serv22296/lib/python/Zope/App/Publisher/Browser
Modified Files:
I18nResourceMeta.py
Log Message:
Check that i18n-resource directive specifies a translation for the
default language, and that it does not contain translations of different
types (no mixing of text and images).
=== Zope3/lib/python/Zope/App/Publisher/Browser/I18nResourceMeta.py 1.1 => 1.2 ===
self.permission = permission
self.__data = {}
+ self.__format = None
def translation(self, _context, language, file=None, image=None):
@@ -53,9 +54,21 @@
"attributes for resource directives"
)
elif file is not None:
+ if self.__format is not None and self.__format != File:
+ raise ConfigurationError(
+ "Can't use both files and images in the same "
+ "i18n-resource directive"
+ )
self.__data[language] = File(_context.path(file))
+ self.__format = File
elif image is not None:
+ if self.__format is not None and self.__format != Image:
+ raise ConfigurationError(
+ "Can't use both files and images in the same "
+ "i18n-resource directive"
+ )
self.__data[language] = Image(_context.path(image))
+ self.__format = Image
else:
raise ConfigurationError(
"At least one of the file, and image "
@@ -68,6 +81,12 @@
def __call__(self, require = None):
if self.name is None:
return ()
+
+ if not self.__data.has_key(self.defaultLanguage):
+ raise ConfigurationError(
+ "A translation for the default language (%s) "
+ "must be specified" % self.defaultLanguage
+ )
permission = self.permission
factory = I18nFileResourceFactory(self.__data, self.defaultLanguage)