search for existing translations if the chosen language is not documented

This commit is contained in:
lars 2006-11-29 13:40:33 +00:00
parent ec73772334
commit c9f8aea976
2 changed files with 25 additions and 6 deletions

View file

@ -4,6 +4,6 @@
<div id="doc">
<?cs include:Settings.DocDir + '/' + Settings.Language + '/' + Data.Plugins.help.Page + '.html' ?>
<?cs include:Settings.DocDir + '/' + Data.Plugins.help.Language + '/' + Data.Plugins.help.Page + '.html' ?>
</div>

View file

@ -7,16 +7,35 @@ class help(cryptobox.plugins.base.CryptoBoxPlugin):
requestAuth = False
rank = 80
default_lang = 'en'
default_page = "CryptoBoxUser"
def doAction(self, page=""):
'''prints the offline wikipage
'''
import re
## check for invalid characters
if page and not re.search(u'\W', page):
self.hdf[self.hdf_prefix + "Page"] = page
import re,os
## check for invalid characters and if the page exists in the default language
if page and \
not re.search(u'\W', page) and \
os.path.isfile(os.path.join(self.cbox.prefs["Locations"]["DocDir"], self.efault_lang, page + '.html')):
## everything is ok
pass
else:
## display this page as default help page
self.hdf[self.hdf_prefix + "Page"] ="CryptoBoxUser"
page = self.default_page
if page:
## issue warning
self.cbox.log.info("could not find the selected documentation page: %s" % str(page))
## store the name of the page
self.hdf[self.hdf_prefix + "Page"] = page
## choose the right language
for l in self.site.langOrder:
if os.path.isfile(os.path.join(self.cbox.prefs["Locations"]["DocDir"], l, page + '.html')):
lang = l
break
else:
lang = self.default_lang
self.hdf[self.hdf_prefix + "Language"] = lang
return "doc"