Skip to content

Commit

Permalink
Merge 77049ce into 5525f0d
Browse files Browse the repository at this point in the history
  • Loading branch information
Gjum committed Sep 19, 2015
2 parents 5525f0d + 77049ce commit 5370413
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions spock/plugins/helpers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@

translations = {}
try:
with open('en_US.lang', 'r') as trf:
for line in trf:
with open('en_US.lang', 'r') as lang_file:
# the chat data comes in as strings, so we need to
# replace all %d, %i, %3$d etc. with %s
import re
pcts_only = re.compile('%([0-9]\$)?[a-z]')
for line in lang_file:
if '=' in line:
# cut off newline, split some.translation.id=format %s string
translation_id, format_str = line[:-1].split('=', 1)
translations[translation_id] = format_str
translations[translation_id] = pcts_only.sub('%s', format_str)
except:
logger.warn('en_US.lang not loaded, cannot translate chat messages')

Expand Down

0 comments on commit 5370413

Please sign in to comment.