Skip to content

Commit

Permalink
[#2774] I18n js strings full sprintf support
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Aug 6, 2012
1 parent c9b9e3a commit b0eec93
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ckan/lib/cli.py
Expand Up @@ -1549,8 +1549,14 @@ def mangle_po(self):
pot_path = os.path.join(self.i18n_path, 'ckan.pot')
po = polib.pofile(pot_path)
# we don't want to mangle the following items in strings
# [1:...] %(...)s %s {...}
extract_reg_ex = '(\[\d*\:[^\]]*\]|\%\([^\)]*\)s|\%(\d)*s|\{[^\}]*\})'
# %(...)s %s %0.3f etc

# sprintf bit after %
spf_reg_ex = "\+?(0|'.)?-?\d*(.\d*)?[\%bcdeufosxX"

extract_reg_ex = '(\%\([^\)]*\)' + spf_reg_ex + \
'|\%(\d)*' + spf_reg_ex + ')'

for entry in po:
msg = entry.msgid.encode('utf-8')
matches = re.finditer(extract_reg_ex, msg)
Expand Down

0 comments on commit b0eec93

Please sign in to comment.