appy.shared: added support for country codes (iso-3166-1) - appy.gen: non-string variables are now allowed in i18n variable replacements; bugfix while browsing translation pages with the 'next' arrows in 'edit' mode.
This commit is contained in:
parent
4e848ce0a8
commit
9e7ddcc771
7 changed files with 298 additions and 14 deletions
|
@ -8,7 +8,7 @@ from appy.gen.utils import sequenceTypes, GroupDescr, Keywords, FileWrapper, \
|
|||
getClassName, SomeObjects
|
||||
import appy.pod
|
||||
from appy.pod.renderer import Renderer
|
||||
from appy.shared.data import languages
|
||||
from appy.shared.data import countries
|
||||
from appy.shared.utils import Traceback, getOsTempFolder
|
||||
|
||||
# Default Appy permissions -----------------------------------------------------
|
||||
|
@ -1066,7 +1066,7 @@ class String(Type):
|
|||
# Maximum size is 34 chars
|
||||
if (len(v) < 8) or (len(v) > 34): return False
|
||||
# 2 first chars must be a valid country code
|
||||
if not languages.exists(v[:2].lower()): return False
|
||||
if not countries.exists(v[:2].upper()): return False
|
||||
# 2 next chars are a control code whose value must be between 0 and 96.
|
||||
try:
|
||||
code = int(v[2:4])
|
||||
|
@ -1095,7 +1095,7 @@ class String(Type):
|
|||
for c in value[:4]:
|
||||
if not letter.match(c): return False
|
||||
# 2 next chars must be a valid country code
|
||||
if not languages.exists(value[4:6].lower()): return False
|
||||
if not countries.exists(value[4:6].upper()): return False
|
||||
# Last chars represent some location within a country (a city, a
|
||||
# province...). They can only be letters or figures.
|
||||
for c in value[6:]:
|
||||
|
|
|
@ -1245,6 +1245,7 @@ class BaseMixin:
|
|||
res = self.formatText(res, format)
|
||||
# Perform variable replacements
|
||||
for name, repl in mapping.iteritems():
|
||||
if not isinstance(repl, basestring): repl = str(repl)
|
||||
res = res.replace('${%s}' % name, repl)
|
||||
return res
|
||||
|
||||
|
|
|
@ -563,8 +563,6 @@
|
|||
<td width="80%">
|
||||
<b class="appyTitle" tal:content="contextObj/title_or_id"></b>
|
||||
</td>
|
||||
<td><metal:actions use-macro="here/document_actions/macros/document_actions"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr tal:define="descrLabel python: contextObj.translate('%s_edit_descr' % contextObj.portal_type)"
|
||||
tal:condition="descrLabel/strip" align="left">
|
||||
|
|
|
@ -22,9 +22,10 @@ class TranslationWrapper(AbstractWrapper):
|
|||
else:
|
||||
sourceMsg = getattr(sourceTranslation,fieldName)
|
||||
# When editing the value, we don't want HTML code to be interpreted.
|
||||
# This way, the translator sees the HTML tags and can reproduce them in
|
||||
# the translation.
|
||||
if self.request['URL'].endswith('/skyn/edit'):
|
||||
# This way, the translator sees the HTML tags and can reproduce them
|
||||
# in the translation.
|
||||
url = self.request['URL']
|
||||
if url.endswith('/skyn/edit') or url.endswith('/skyn/do'):
|
||||
sourceMsg = sourceMsg.replace('<','<').replace('>','>')
|
||||
sourceMsg = sourceMsg.replace('\n', '<br/>')
|
||||
return '<div class="translationLabel"><acronym title="%s">' \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue