search for existing translations if the chosen language is not documented
This commit is contained in:
parent
ec73772334
commit
c9f8aea976
|
@ -4,6 +4,6 @@
|
||||||
|
|
||||||
<div id="doc">
|
<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>
|
</div>
|
||||||
|
|
|
@ -7,16 +7,35 @@ class help(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
requestAuth = False
|
requestAuth = False
|
||||||
rank = 80
|
rank = 80
|
||||||
|
|
||||||
|
default_lang = 'en'
|
||||||
|
default_page = "CryptoBoxUser"
|
||||||
|
|
||||||
def doAction(self, page=""):
|
def doAction(self, page=""):
|
||||||
'''prints the offline wikipage
|
'''prints the offline wikipage
|
||||||
'''
|
'''
|
||||||
import re
|
import re,os
|
||||||
## check for invalid characters
|
## check for invalid characters and if the page exists in the default language
|
||||||
if page and not re.search(u'\W', page):
|
if page and \
|
||||||
self.hdf[self.hdf_prefix + "Page"] = page
|
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:
|
else:
|
||||||
## display this page as default help page
|
## 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"
|
return "doc"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue