Show localized times if locales are generated for this country
This commit is contained in:
parent
eae87ee0ec
commit
d8b98ca5fb
52
blogthon.cgi
52
blogthon.cgi
@ -16,8 +16,17 @@
|
|||||||
# * Complete Atom Feed (like RSS)
|
# * Complete Atom Feed (like RSS)
|
||||||
# * Fix broken charset in outgoing mails (needs some testing)
|
# * Fix broken charset in outgoing mails (needs some testing)
|
||||||
|
|
||||||
import cgi, os, time, glob, re, md5, sys, random, smtplib
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import locale
|
||||||
|
import re
|
||||||
|
import cgi
|
||||||
|
import glob
|
||||||
|
import md5
|
||||||
|
import random
|
||||||
|
import smtplib
|
||||||
|
|
||||||
# A wonderful place for doing some regexp ;)
|
# A wonderful place for doing some regexp ;)
|
||||||
no_break = re.compile('^\s*(<ul|</ul>|<li|</li>|<ol|</ol>|<table|</table>|<tr|</tr>|<td|</td>|<th|</th>|<p|</p>).*$')
|
no_break = re.compile('^\s*(<ul|</ul>|<li|</li>|<ol|</ol>|<table|</table>|<tr|</tr>|<td|</td>|<th|</th>|<p|</p>).*$')
|
||||||
@ -111,10 +120,25 @@ except: errorpage('"style" is missing in configuration!')
|
|||||||
|
|
||||||
try: language = configuration.get('look', 'language')
|
try: language = configuration.get('look', 'language')
|
||||||
except: errorpage('"language" is missing in configuration!')
|
except: errorpage('"language" is missing in configuration!')
|
||||||
if language == "de" or language == "at":
|
if language == "de":
|
||||||
locale = ("Seiten", "Monate", "Links", "Keine Kommentare", "Kommentare", "Alle Einträge anzeigen...", "Name", "Text", "Absenden")
|
blog_locale = ("Seiten", "Monate", "Links", "Keine Kommentare", "Kommentare", "Alle Einträge anzeigen...", "Name", "Text", "Absenden")
|
||||||
|
locales_de = ("de_DE.UTF-8", "de_DE.@euro", "de_DE")
|
||||||
|
for i in locales_de:
|
||||||
|
try:
|
||||||
|
locale.setlocale(locale.LC_TIME, i)
|
||||||
|
break
|
||||||
|
except: continue
|
||||||
|
else: locale.setlocale(locale.LC_TIME, None)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
locale = ("pages", "months", "links", "no comments", "comments", "View all entries...", "name", "text", "commit")
|
blog_locale = ("pages", "months", "links", "no comments", "comments", "View all entries...", "name", "text", "commit")
|
||||||
|
locales_en = ("en_US.UTF-8", "en_US.ISO-8859-15", "en_US")
|
||||||
|
for i in locales_en:
|
||||||
|
try:
|
||||||
|
locale.setlocale(locale.LC_TIME, i)
|
||||||
|
break
|
||||||
|
except: continue
|
||||||
|
else: locale.setlocale(locale.LC_TIME, None)
|
||||||
|
|
||||||
try: entries_per_page = configuration.getint('look', 'entries_per_page')
|
try: entries_per_page = configuration.getint('look', 'entries_per_page')
|
||||||
except: errorpage('"entries_per_page" is missing in configuration!')
|
except: errorpage('"entries_per_page" is missing in configuration!')
|
||||||
@ -201,7 +225,7 @@ if cname and ctext and ctitle:
|
|||||||
try:
|
try:
|
||||||
content = open(entries_dir + ctitle + '.comments', "a")
|
content = open(entries_dir + ctitle + '.comments', "a")
|
||||||
content.write("-." + cname + "\n")
|
content.write("-." + cname + "\n")
|
||||||
content.write("+." + time.asctime() + "\n")
|
content.write("+." + time.strftime("%c", time.localtime()) + "\n")
|
||||||
ctext = ctext.split("\n")
|
ctext = ctext.split("\n")
|
||||||
for line in ctext:
|
for line in ctext:
|
||||||
content.write("." + line + "\n")
|
content.write("." + line + "\n")
|
||||||
@ -353,7 +377,7 @@ else:
|
|||||||
staticpages_list = glob.glob(staticpages_dir + '*')
|
staticpages_list = glob.glob(staticpages_dir + '*')
|
||||||
staticpages_list.sort()
|
staticpages_list.sort()
|
||||||
print ' <div class="pages">'
|
print ' <div class="pages">'
|
||||||
print ' <div class="pages_title">' + locale[0] + '</div>'
|
print ' <div class="pages_title">' + blog_locale[0] + '</div>'
|
||||||
print ' <div class="pages_list">'
|
print ' <div class="pages_list">'
|
||||||
print ' <ul class="pages_list">'
|
print ' <ul class="pages_list">'
|
||||||
for staticpage in staticpages_list:
|
for staticpage in staticpages_list:
|
||||||
@ -377,7 +401,7 @@ else:
|
|||||||
if monthlist == "True":
|
if monthlist == "True":
|
||||||
olddate = ""
|
olddate = ""
|
||||||
print ' <div class="months">'
|
print ' <div class="months">'
|
||||||
print ' <div class="months_title">' + locale[1] + '</div>'
|
print ' <div class="months_title">' + blog_locale[1] + '</div>'
|
||||||
print ' <div class="months_list">'
|
print ' <div class="months_list">'
|
||||||
print ' <ul class="months_list">'
|
print ' <ul class="months_list">'
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
@ -395,7 +419,7 @@ else:
|
|||||||
# Linklist
|
# Linklist
|
||||||
if linklist == "True":
|
if linklist == "True":
|
||||||
print ' <div class="linklist">'
|
print ' <div class="linklist">'
|
||||||
print ' <div class="linklist_title">' + locale[2] + '</div>'
|
print ' <div class="linklist_title">' + blog_locale[2] + '</div>'
|
||||||
print ' <div class="linklist_list">'
|
print ' <div class="linklist_list">'
|
||||||
print ' <ul class="linklist_list">'
|
print ' <ul class="linklist_list">'
|
||||||
try:
|
try:
|
||||||
@ -526,10 +550,10 @@ else:
|
|||||||
print ' <form action="" method="post">'
|
print ' <form action="" method="post">'
|
||||||
print ' <input type="hidden" name="ctitle" value="' + title + '" />'
|
print ' <input type="hidden" name="ctitle" value="' + title + '" />'
|
||||||
print ' <input type="hidden" name="cquizv" value="' + str(cquizv) + '" />'
|
print ' <input type="hidden" name="cquizv" value="' + str(cquizv) + '" />'
|
||||||
print ' <label class="submit_comment_name">' + locale[6] + ':</label><input class="submit_comment_name_input" type="text" id="cname" name="cname" />'
|
print ' <label class="submit_comment_name">' + blog_locale[6] + ':</label><input class="submit_comment_name_input" type="text" id="cname" name="cname" />'
|
||||||
print ' <br /><label class="submit_comment_text">' + locale[7] + ':</label><textarea class="submit_comment_textarea" id="ctext" name="ctext"></textarea>'
|
print ' <br /><label class="submit_comment_text">' + blog_locale[7] + ':</label><textarea class="submit_comment_textarea" id="ctext" name="ctext"></textarea>'
|
||||||
print ' <br /><label class="submit_comment_quiz">' + str(random_int_a) + '+' + str(random_int_b) + '=</label><input class="submit_comment_quiz_input" type="text" id="cquiz" name="cquiz" />'
|
print ' <br /><label class="submit_comment_quiz">' + str(random_int_a) + '+' + str(random_int_b) + '=</label><input class="submit_comment_quiz_input" type="text" id="cquiz" name="cquiz" />'
|
||||||
print ' <br /><input class="submit_comment_button" type="submit" id="submit" value="' + locale[8] + '" />'
|
print ' <br /><input class="submit_comment_button" type="submit" id="submit" value="' + blog_locale[8] + '" />'
|
||||||
print ' </form>'
|
print ' </form>'
|
||||||
print ' </div>'
|
print ' </div>'
|
||||||
else:
|
else:
|
||||||
@ -540,7 +564,7 @@ else:
|
|||||||
comments_file = glob.glob(entries_dir + title + '.comments')
|
comments_file = glob.glob(entries_dir + title + '.comments')
|
||||||
if not comments_file and not post_display:
|
if not comments_file and not post_display:
|
||||||
print ' <div class="entry_comment">'
|
print ' <div class="entry_comment">'
|
||||||
print ' <a href="?p=' + title.replace(' ','-') + '" class="entry_comment">' + locale[3] + '</a>'
|
print ' <a href="?p=' + title.replace(' ','-') + '" class="entry_comment">' + blog_locale[3] + '</a>'
|
||||||
print ' </div>'
|
print ' </div>'
|
||||||
print ' </div>'
|
print ' </div>'
|
||||||
print ''
|
print ''
|
||||||
@ -550,7 +574,7 @@ else:
|
|||||||
for line in comments_content:
|
for line in comments_content:
|
||||||
if line.split(".", 1)[0] == "-": comments_counter += 1
|
if line.split(".", 1)[0] == "-": comments_counter += 1
|
||||||
print ' <div class="entry_comment">'
|
print ' <div class="entry_comment">'
|
||||||
print ' <a href="?p=' + title.replace(' ', '-') + '" class="entry_comment">' + locale[4] + ' (' + str(comments_counter) + ')</a>'
|
print ' <a href="?p=' + title.replace(' ', '-') + '" class="entry_comment">' + blog_locale[4] + ' (' + str(comments_counter) + ')</a>'
|
||||||
print ' </div>'
|
print ' </div>'
|
||||||
print ' </div>'
|
print ' </div>'
|
||||||
print ''
|
print ''
|
||||||
@ -563,7 +587,7 @@ else:
|
|||||||
entry_counter += 1
|
entry_counter += 1
|
||||||
|
|
||||||
if not month_display and not post_display and not allentries_display and entry_counter == entries_per_page: # Display pagelist
|
if not month_display and not post_display and not allentries_display and entry_counter == entries_per_page: # Display pagelist
|
||||||
print ' <div class="entry"><a href=?a=1>' + locale[5] + '</a></div>'
|
print ' <div class="entry"><a href=?a=1>' + blog_locale[5] + '</a></div>'
|
||||||
|
|
||||||
print ' </div>'
|
print ' </div>'
|
||||||
print ''
|
print ''
|
||||||
|
Loading…
Reference in New Issue
Block a user