Ticket #6693: datetime-i18n.py

File datetime-i18n.py, 935 bytes (added by Petr Marhoun <petr.marhoun@…>, 17 years ago)

a fast script for 2

Line 
1#!/usr/bin/python
2
3from glob import glob
4
5FILES = '%s/LC_MESSAGES/django.po'
6FORMATS = 'DATE_FORMAT', 'DATETIME_FORMAT', 'TIME_FORMAT', 'YEAR_MONTH_FORMAT', 'MONTH_DAY_FORMAT'
7
8EN = 'en'
9OUTPUT = '\nmsgid "%s"\nmsgstr "%s"\n'
10
11data = {}
12
13for file in glob(FILES % '*'):
14 language = file.split('/')[0]
15 data[language] = {}
16 format = None
17 for line in open(file):
18 try:
19 content = line.strip().split(None, 1)[1].strip('"')
20 if format:
21 if content and content != format:
22 data[language][format] = content
23 format = None
24 elif content in FORMATS:
25 format = content
26 except:
27 pass
28
29for language in data:
30 file = open(FILES % language, 'a')
31 for format in FORMATS:
32 key = data[EN][format]
33 value = data[language].get(format, key)
34 file.write(OUTPUT % (key, value))
35 file.close()
Back to Top