[merging i18n work.
getzdan@gmail.com**20070204134914] {
hunk ./app/accounts.py 9
+from ghestalt.i18n.utils import i18n_site_base
hunk ./app/accounts.py 14
+from django.utils import translation
hunk ./app/accounts.py 17
-    email = forms.EmailField()
-    password = forms.CharField(widget=forms.PasswordInput)
-    password2 = forms.CharField(widget=forms.PasswordInput)
-    first_name = forms.CharField(max_length=30)
-    last_name = forms.CharField(max_length=30)
-    user_name = forms.CharField(max_length=30)
+    email = forms.EmailField(label=_('E-mail address'))
+    password = forms.CharField(label=_('Password'),widget=forms.PasswordInput)
+    password2 = forms.CharField(label=_('Password (again)'),widget=forms.PasswordInput)
+    first_name = forms.CharField(label=_('First name'),max_length=30)
+    last_name = forms.CharField(label=_('Last name'),max_length=30)
+    user_name = forms.CharField(label=_('Account username'),max_length=30)
+    location = forms.CharField(label=_('Location'),max_length=30, required=False)
+    otro_lang = forms.ChoiceField(label=_('Language'),choices=settings.LANGUAGES, required=False)
+    otro_first_name = forms.CharField(label=_('First name in language'),max_length=30, required=False)
+    otro_last_name = forms.CharField(label=_('Last name in language'),max_length=30, required=False)
hunk ./app/accounts.py 31
+    def clean_location(self):
+        raw = self.clean_data.get('location')
+        if raw=='':
+            return raw
+        raw2 = map(unicode.upper,map(unicode.strip,raw.split(',')))
+        if len(raw2) != 2:
+            raise forms.ValidationError(_(u'Cannot parse location. Format is lat,long.'))
+        if raw2[0][-1] in 'NS':
+            if raw2[0][0]=='-':
+                raise forms.ValidationError(_(u'Cannot parse location. Format is lat,long.'))
+            if raw2[0][-1]=='S':
+                raw2[0] = '-'+raw2[0][:-1]
+            if raw2[0][-1]=='N':
+                raw2[0] = raw2[0][:-1]
+        if raw2[1][-1] in 'EW':
+            if raw2[1][0]=='-':
+                raise forms.ValidationError(_(u'Cannot parse location. Format is lat,long.'))
+            if raw2[1][-1]=='W':
+                raw2[1] = '-'+raw2[1][:-1]
+            if raw2[1][-1]=='E':
+                raw2[1] = raw2[1][:-1]
+        try:
+            long,lat = (float(raw2[0]),float(raw2[1]))
+        except ValueError:
+            raise forms.ValidationError(_(u'Cannot parse location. Format is lat,long.'))
+        return '%f,%f' % (long,lat)
hunk ./app/accounts.py 75
+            location = form.clean_data.get('location')
+            otro_lang = form.clean_data.get('otro_lang')
+            otro_first_name = form.clean_data.get('otro_first_name')
+            otro_last_name = form.clean_data.get('otro_last_name')
hunk ./app/accounts.py 83
-            userprofile = UserProfile(first_name=first_name, last_name=last_name, email=email, role="User", user=u)
+            userprofile = UserProfile(first_name=first_name, last_name=last_name, email=email, role="User", user=u, location=location,otro_lang=otro_lang, otro_last_name=otro_last_name, otro_first_name=otro_first_name)
hunk ./app/accounts.py 91
-            subject = "Welcome to %s" % (settings.SITE_NAME)
-            c['login_url'] = "%s%s/accounts/login" % (settings.SITE_DOMAIN, settings.SITE_BASE)
+            subject = _("Welcome to %s" % (settings.SITE_NAME))
+            site_base = i18n_site_base(request)
+            c['login_url'] = "%s%s/accounts/login" % (settings.SITE_DOMAIN, site_base)
hunk ./app/accounts.py 98
-            try:
-                send_mail(subject, t.render(c), site_email,
-                         [email], fail_silently=False)
-            except:
-                return bad_or_missing(request,'Problems sending mail.')
-            return http.HttpResponseRedirect('%s/accounts/thankyou' % (settings.SITE_BASE))
+            if userprofile.otro_lang != settings.LANGUAGE_CODE[:2]:
+                request.session['otro_lang'] = userprofile.otro_lang
+                try:
+                    if request.session['other_lang']: pass
+                except KeyError:
+                    request.session['other_lang'] = userprofile.otro_lang
+            if settings.ENABLE_MAIL:
+                try:
+                    send_mail(subject, t.render(c), site_email,
+                             [email], fail_silently=False)
+                except:
+                    return bad_or_missing(request,'Problems sending mail.')
+            return http.HttpResponseRedirect('%s/accounts/thankyou' % (site_base))
hunk ./app/accounts.py 115
+##
+class EditAccountForm(forms.Form):
+    first_name = forms.CharField(label=_('First name'),max_length=30)
+    last_name = forms.CharField(label=_('Last name'),max_length=30)
+    location = forms.CharField(label=_('Location'),max_length=30,required=False)
+    otro_lang = forms.ChoiceField(label=_('Language'),choices=settings.LANGUAGES,required=False)
+    otro_first_name = forms.CharField(label=_('First name in language'),max_length=30,required=False)
+    otro_last_name = forms.CharField(label=_('Last name in language'),max_length=30,required=False)
+    def clean_location(self):
+        raw = self.clean_data.get('location')
+        if raw=='':
+            return raw
+        raw2 = map(unicode.upper,map(unicode.strip,raw.split(',')))
+        if len(raw2) != 2:
+            raise forms.ValidationError(_(u'Cannot parse location. Format is lat,long.'))
+        if raw2[0][-1] in 'NS':
+            if raw2[0][0]=='-':
+                raise forms.ValidationError(_(u'Cannot parse location. Format is lat,long.'))
+            if raw2[0][-1]=='S':
+                raw2[0] = '-'+raw2[0][:-1]
+            if raw2[0][-1]=='N':
+                raw2[0] = raw2[0][:-1]
+        if raw2[1][-1] in 'EW':
+            if raw2[1][0]=='-':
+                raise forms.ValidationError(_(u'Cannot parse location. Format is lat,long.'))
+            if raw2[1][-1]=='W':
+                raw2[1] = '-'+raw2[1][:-1]
+            if raw2[1][-1]=='E':
+                raw2[1] = raw2[1][:-1]
+        try:
+            long,lat = (float(raw2[0]),float(raw2[1]))
+        except ValueError:
+            raise forms.ValidationError(_(u'Cannot parse location. Format is lat,long.'))
+        return '%f,%f' % (long,lat)
+    def clean(self):
+        return self.clean_data
+    
+def edit(request):
+    if request.POST:
+        form = EditAccountForm(request.POST)
+        if form.is_valid():
+            first_name = form.clean_data.get('first_name')
+            last_name = form.clean_data.get('last_name')
+            otro_lang = form.clean_data.get('otro_lang')
+            otro_first_name = form.clean_data.get('otro_first_name')
+            otro_last_name = form.clean_data.get('otro_last_name')
+            location = form.clean_data.get('location')
+            u = User.objects.get(id=request.user.id)
+            userprofile = UserProfile.objects.get(user=u.id)
+            u.first_name = first_name
+            u.last_name = last_name
+            u.save()
+            userprofile.first_name=first_name
+            userprofile.last_name=last_name
+            userprofile.role="User"
+            userprofile.user=u
+            userprofile.location=location
+            userprofile.otro_lang=otro_lang
+            userprofile.otro_last_name=otro_last_name
+            userprofile.otro_first_name=otro_first_name
+            userprofile.save()
+            if userprofile.otro_lang != settings.LANGUAGE_CODE[:2]:
+                request.session['otro_lang'] = userprofile.otro_lang
+                try:
+                    if request.session['other_lang']: pass
+                except KeyError:
+                    request.session['other_lang'] = userprofile.otro_lang
+            site_base = i18n_site_base(request)
+            return http.HttpResponseRedirect('%s/accounts/thankyou' % (site_base))
+    else:
+        userprofile = UserProfile.objects.get(user=request.user.id)
+        user = User.objects.get(id=request.user.id)
+        d = userprofile.__dict__
+        d.update(user.__dict__)
+        form = EditAccountForm(d)
+    return render_to_response('account_edit_form.html', {'form': form},
+                                RequestContext(request))
+edit = login_required(edit)
hunk ./app/accounts.py 206
-    return http.HttpResponseRedirect('%s/' % (settings.SITE_BASE))
+    site_base = i18n_site_base(request)
+    return http.HttpResponseRedirect('%s/' % (site_base))
hunk ./app/contact.py 11
-    ("General Question", "General question"),
-    ("Improvement Suggestion", "Improvement suggestion"),
+    ("General Question", _("General question")),
+    ("Improvement Suggestion", _("Improvement suggestion")),
hunk ./app/contact.py 16
-    name = forms.CharField(max_length=20)
-    email = forms.EmailField()
-    subject = forms.CharField(max_length=30)
-    inquiry = forms.ChoiceField(choices=email_choices)
-    contents = forms.CharField(widget=forms.Textarea(attrs={'rows': 14, 'cols': 60}))
+    name = forms.CharField(label=_('Name'),max_length=20)
+    email = forms.EmailField(label=_('E-mail address'))
+    subject = forms.CharField(label=_('Subject'),max_length=30)
+    inquiry = forms.ChoiceField(label=_('Inquiry'),choices=email_choices)
+    contents = forms.CharField(label=_('Contents'),widget=forms.Textarea(attrs={'rows': 14, 'cols': 60}))
hunk ./app/contact.py 36
-            try:
-                send_mail(subject, t.render(c), site_email,
-                          [site_email], fail_silently=False)
-            except:
-                return bad_or_missing(request,'Problems sending mail.')
+            if settings.ENABLE_MAIL:
+                try:
+                    send_mail(subject, t.render(c), site_email,
+                             [site_email], fail_silently=False)
+                except:
+                    return bad_or_missing(request,'Problems sending mail.')
hunk ./app/context_processors.py 8
+from django.utils import translation
+from ghestalt.i18n.utils import *
hunk ./app/context_processors.py 13
-    site_name = settings.SITE_NAME
-    return {'site_base': settings.SITE_BASE,
+    site_name = _(settings.SITE_NAME)
+    site_base = i18n_site_base(request)
+    try:
+        other_lang = str(request.session['other_lang'])
+    except KeyError:
+        other_lang = None
+    gui_lang = request.LANGUAGE_CODE[:2]
+    try:
+        otro_lang = str(request.session['otro_lang'])
+    except KeyError:
+        otro_lang = None
+    if i18n_lang_suffix(request.path)[1:] in settings.LANGUAGES_BIDI:
+        content_bidi = True
+    else:
+        content_bidi = False
+    return {'site_base': site_base,
+            'site_root': settings.SITE_BASE,
hunk ./app/context_processors.py 31
-            'media_url': settings.MEDIA_URL}
+            'media_url': settings.MEDIA_URL,
+            'url_path': request.path,
+            'other_lang': other_lang,
+            'gui_lang': gui_lang,
+            'base_lang': settings.LANGUAGE_CODE[:2],
+            'otro_lang': otro_lang,
+            }
hunk ./app/models.py 1
+from django.conf import settings
hunk ./app/models.py 4
+from django.utils.translation import gettext_lazy as _
hunk ./app/models.py 21
-    create_date = models.DateField(auto_now_add=True)
+    create_date = models.DateField(auto_now_add=True,null=True)
hunk ./app/models.py 26
-    
+    otro_lang = models.CharField(_('Language'),null=True,maxlength=10,choices=settings.LANGUAGES,default=settings.LANGUAGE_CODE[:2], blank=True)
+    # when viewing content in otro_lang your name will appear as otro_name
+    otro_first_name = models.CharField(null=True,maxlength=30, blank=True)
+    otro_last_name = models.CharField(null=True,maxlength=30, blank=True)
+    def _get_otro_full_name(self):
+        "Returns the person's otro language name."
+        return '%s %s' % (self.otro_first_name, self.otro_last_name)
+    otro_full_name = property(_get_otro_full_name)
hunk ./app/models.py 45
-    mtime = models.DateTimeField(auto_now = True)
+    mtime = models.DateTimeField(auto_now = True,null=True)
hunk ./app/models.py 47
-    msg = models.TextField(maxlength=65535)
+    msg = models.TextField(maxlength=65535,null=True)
hunk ./app/templates/account.html 1
+{% load ghmarkup %}
hunk ./app/templates/account.html 11
-<p>Welcome, {{ user_data.full_name }}.</p> 
+<p>Welcome, {{ user_data.full_name }}.</p>
+<p>Your recorded long/lat is {{ user_data.location }}.</p>
+<p>Otro language: {{ user_data.otro_lang|prettylang }}.</p>
+<p>Otro name: {{ user_data.otro_last_name }}, {{ user_data.otro_first_name }}.</p>
hunk ./app/templates/account.html 17
+<li><a href="{{site_base}}/accounts/edit/">Edit user details</a></li>
hunk ./app/templates/base.html 1
+{% load ghmarkup %}
hunk ./app/templates/base.html 48
-            
+<p><small>Viewing site in {{ gui_lang|prettylang }}<br/>
+{% ifnotequal base_lang gui_lang %}
+            Change to <a href="/intl/{{ base_lang }}/">{{ base_lang|prettylang }}</a><br/>
+{% endifnotequal %}
+{% if other_lang %}{% ifnotequal other_lang gui_lang %}
+            Change to <a href="/intl/{{ other_lang }}/">{{ other_lang|prettylang }}</a><br/>
+{% endifnotequal %}{% endif %}
+{% if otro_lang %}
+  {% ifnotequal otro_lang gui_lang %}
+    {% ifnotequal otro_lang other_lang %}
+            Change to <a href="/intl/{{ otro_lang }}/">{{ otro_lang|prettylang }}</a><br/>
+    {% endifnotequal %}
+  {% endifnotequal %}
+{% endif %}
+            <a href="/intl/?next={{url_path|urlencode}}">Other Languages</a><br/>
+</small><br/>
+</p>
hunk ./app/templates/edit.html 12
-    {% if preview %}{{ preview|ghmarkup }}{% endif %}
+    {% if source %}<h3>Translation source</h3>{{ source|ghmarkup:what }}{% endif %}
+    {% if preview %}{{ preview|ghmarkup:what }}{% endif %}
hunk ./app/templates/edit.html 16
-      <input type="submit" name="submit" value="Preview"/>
-      <input type="submit" name="submit" value="Save"/>
+      <input type="submit" name="_preview" value="Preview"/>
+      <input type="submit" name="_save" value="Save"/>
hunk ./app/templates/history.html 12
-<li><a href="/wiki/{{ entry.id }}/">{{ entry.id }}</a> {{ entry.mtime }} {{ entry.what|ghlink }}
-  ... {% filter ghlink %}user/{{ entry.muser }}{% endfilter %}</li>
+<li><a href="{{ site_base }}/wiki/{{ entry.id }}/">{{ entry.id }}</a> {{ entry.mtime }} {{ entry.what|ghlink }}
+  ... {{ entry.muser|userlink:"/user/history" }}</li>
hunk ./app/templates/intro.html 2
+{% load ghmarkup %}
hunk ./app/templates/intro.html 11
-      Welcome to Ghestalt{% if user.username %}, {{ user.username }}{% endif %}.
+      Welcome to Ghestalt{% if user.username %}, {{ user.username|userlink:"/intro" }}{% endif %}.
hunk ./app/templates/intro.html 14
-<p>You can <a href="/accounts/login/">Login</a>, or go straight to the <a href="/wiki/">Wiki</a>.
+<p>You can <a href="{{ site_base }}/accounts/login/">Login</a>, or go straight to the <a href="/wiki/">Wiki</a>.
hunk ./app/templates/intro.html 17
-<p>Go straight to the <a href="/wiki/">Wiki</a>.
+<p>Go straight to the <a href="{{ site_base }}/wiki/">Wiki</a>.
hunk ./app/templates/missing.html 15
-<a rel="nofollow" href="/edit/{{ what|urlencode }}">Add page</a>
+<a rel="nofollow" href="{{ site_base }}/edit/{{ what|urlencode }}">Add page</a>
hunk ./app/templates/recent.html 12
-<li><a href="/wiki/{{ entry.id }}/">{{ entry.id }}</a> {{ entry.mtime }} {{entry.what|ghlink}}
-  ... {% filter ghlink %}user/{{ entry.muser }}{% endfilter %}</li>
+{% ifchanged entry.mtime.date %}</ul><em>{{ entry.mtime.date }}</em><ul>{% endifchanged %}
+<li><a href="{{ site_base }}/wiki/{{ entry.id }}/">{{ entry.id }}</a> {{ entry.mtime|date:"P" }} {{entry.what|ghlink}}
+  ... {{ entry.muser|userlink:"/user/recent" }}</li>
hunk ./app/templates/theorem.html 7
-{{ norm.ldata|ghmarkup:"mm/set/" }}
+{% if origwhat %}
+<div class="new">Translated version missing. Click Translate on page bottom to add it yourself.
+</div><br/>
+{% endif %}
+
+{% ghmarkuptag %}{{ norm.ldata }}{% endghmarkuptag %}
hunk ./app/templates/theorem.html 20
-<div class="lastedit">Last edited: {{ norm.mtime }} by {% filter ghlink %}user/{% if norm.muser %}{{ norm.muser }}{% else %}{{ thm.muser }} {% endif %}{% endfilter %}</div>
+<div class="lastedit">Last edited: {{ norm.mtime }} by {% if norm.muser %}{{ norm.muser|userlink:"/wiki/theorempage" }}{% else %}{{ thm.muser|userlink:"/wiki/theorempage" }} {% endif %}{% endfilter %}</div>
hunk ./app/templates/theorem.html 26
+<a href="{{site_base}}/{{ norm.what|translatelink:what }}">Translate</a>
+</p>
hunk ./app/templates/wiki.html 4
+{% block translation %}
+<small>Available translations<br/>
+{% for lang in all_langs %}
+<a href="{{ site_base }}/{{ lang }}">{{ lang|prettylang }}</a><br/>
+{% endfor %}
+</small>
+{% endblock %}
+
hunk ./app/templates/wiki.html 13
-    <h1 class="wiki">{{ title }}</h1>
+    {% if not no_title %}<h1 {% if CONTENT_BIDI %}dir="rtl"{% endif %} class="wiki">{{ title }}</h1>{% else %}
+    <p class="wiki"><small>[{{ title }}]</small></p>{% endif %}
+{% if origwhat %}
+<div class="new">Translated version missing. Click Translate on page bottom to add it yourself.
+</div><br/>
+{% endif %}
+
+<div {% if CONTENT_BIDI %}dir="rtl"{% endif %}>
+{% ghmarkuptag %}{{ log.ldata }}{% endghmarkuptag %}
+</div>
hunk ./app/templates/wiki.html 24
-{{ log.ldata|ghmarkup }}
+<p>Last edited: {{ log.mtime|date:"d/M/Y P" }} by {{ log.muser|userlink:"/wiki/wikipage" }}</p>
hunk ./app/templates/wiki.html 29
-<a rel="nofollow" href="/edit/{{ log.what|urlencode }}">Edit</a>
-<a href="/history/{{ log.what|urlencode }}">History</a>
-{{ log.what|talklink }}
+<a href="{{site_base}}/edit/{{ log.what|urlencode }}">Edit</a>
+<a href="{{site_base}}/history/{{ log.what|urlencode }}">History</a>
+{{ log.what|talklink:url_path }}
+{% if trans_target %}
+<a href="{{site_base}}/edit/{{ trans_target|urlencode }}?source={{ trans_source|urlencode }}">Translate</a>
+{% endif %}
hunk ./app/templates/wikibase.html 2
+{% load ghmarkup %}
hunk ./app/templates/wikibase.html 10
-<a href="{{site_base}}/wiki/">Wiki Homepage</a><br/>
+<a href="{{site_base}}/wiki/">Wiki Home</a><br/>
hunk ./app/templates/wikibase.html 13
+<br/>
+<a href="{{site_base}}/wiki/NewPage">New Page</a><br/>
+<!-- <a href="{{site_base}}/wiki/UnlinkedPages"> -->Unlinked Pages<!-- </a> --><br/>
+<br/>
+{% block translation %}
+{% endblock %}
hunk ./app/templatetags/ghmarkup.py 7
+from ghestalt.i18n.utils import *
hunk ./app/templatetags/ghmarkup.py 36
-def userlink(uname, body = None):
+def userlink(uname, body = None, i18n_base = '', lang_suffix=''):
+    uname = i18n_baselang(uname)
hunk ./app/templatetags/ghmarkup.py 46
-        
-    realname = profile.first_name+" "+profile.last_name
+    realname = ''
+    if profile.otro_lang != settings.LANGUAGE_CODE[:2] and lang_suffix[1:]==profile.otro_lang:
+        realname = (profile.otro_first_name+" "+profile.otro_last_name).decode('utf-8')
+        realname = ''.join(map(lambda x: '&#%d;' % (ord(x)),realname))
+    if realname=='':
+        realname = (profile.first_name+" "+profile.last_name).decode('utf-8')
+        realname = ''.join(map(lambda x: '&#%d;' % (ord(x)),realname))
hunk ./app/templatetags/ghmarkup.py 55
-    return '<a class="user" href="' + settings.SITE_BASE + '/user/' + uname + '">' + htmlquote(body) + '</a>'
+    return '<a class="user" href="' + i18n_base + '/user/' + uname + '">' + body + '</a>'
hunk ./app/templatetags/ghmarkup.py 57
-def wikilink(str, exists = None, ispreblock = False, ctx = None):
+def wikilink(str, path='', exists = None, ispreblock = False, ctx = None, lang_suffix = '', i18n_base=''):
+    (i18n_base, ctx, lang_suffix) = parse_url_path(path)
hunk ./app/templatetags/ghmarkup.py 75
-	return userlink(link[5:], body)
+	return userlink(link[5:], body, i18n_base=i18n_base, lang_suffix=lang_suffix)
hunk ./app/templatetags/ghmarkup.py 80
-	if ctx and link.find('/') < 0: link = ctx + link
+	if ctx and link.find('/') < 0: link = ctx + '/' + link
hunk ./app/templatetags/ghmarkup.py 87
-	url = wikiurl(link)
+	url = wikiurl(link, lang_suffix=lang_suffix, i18n_base=i18n_base)
+    langtext = ''
hunk ./app/templatetags/ghmarkup.py 90
+        m = re.search('_[a-z][a-z]$', linktext)
+        if m:
+            langcode = linktext[m.start()+1:]
+            if LOCALIZED_LANGAUGE_NAMES.has_key(langcode):
+                linktext = linktext[:m.start()]
+                langtext = ' ('+LOCALIZED_LANGAUGE_NAMES[langcode]+')'
hunk ./app/templatetags/ghmarkup.py 102
-    return '<a ' + aclass + 'href="' + urlquote(url) + '">' + htmlquote(body) + '</a>'
+    return '<a ' + aclass + 'href="' + urlquote(url) + '">' + htmlquote(body) + langtext+'</a>'
hunk ./app/templatetags/ghmarkup.py 104
-def wikiurl(page):
-    return settings.SITE_BASE + '/' + wikiwhat(page)
+def wikiurl(page, lang_suffix='', i18n_base=''):
+    return i18n_base + '/' + wikiwhat(page) + lang_suffix
hunk ./app/templatetags/ghmarkup.py 147
-def process_ghmarkup(str, ctx):
+def parse_url_path(path):
+    if path.startswith('/intl/'):
+        i18n_base = '/'.join(path.split('/',3)[:3])
+        path = ''.join(path.split('/',3)[3:])
+    else:
+        i18n_base = ''
+    if path.find('/')>0:
+        ctx = path.rsplit('/',1)[0]
+        if ctx=='wiki':
+            ctx=''
+    else:
+        ctx = ''
+    lang_suffix = i18n_lang_suffix(path)
+    return (i18n_base, ctx, lang_suffix)
+
+def process_ghmarkup(str, path):
hunk ./app/templatetags/ghmarkup.py 185
-	return wikilink(str, ispreblock = False, ctx = ctx)
+	return wikilink(str, path, ispreblock = False)
hunk ./app/templatetags/ghmarkup.py 293
-def ghmarkup(value, ctx = None):
-    return process_ghmarkup(value, ctx)
+def ghmarkup(value, path = ''):
+    return process_ghmarkup(value, path)
hunk ./app/templatetags/ghmarkup.py 296
-def talklink(value):
+def talklink(value,path=''):
+    (i18n_base, ctx, lang_suffix) = parse_url_path(path)
hunk ./app/templatetags/ghmarkup.py 300
-	return wikilink(value[:-5] + '|Main page')
+	return wikilink(value[:-5] + '|'+_('Main page'),path)
hunk ./app/templatetags/ghmarkup.py 302
-	return wikilink(value + '/talk|Discuss')
+	return wikilink(value + '/talk|'+_('Discuss'),path)
+
+def translatelink(value, what = None):
+    if value != what:
+        return 'edit/'+urlquote(what)
+    return 'edit/'+urlquote(value)
+
+def prettylang(value):
+    if not value:
+        value = settings.LANGUAGE_CODE[:2]
+    if len(value)>3:
+        if value[-3]=='_':
+            value = value[-2:]
+        else:
+            value = settings.LANGUAGE_CODE[:2]
+    if LOCALIZED_LANGAUGE_NAMES.has_key(value):
+        return LOCALIZED_LANGAUGE_NAMES[value]
+    else:
+        if settings.LANGUAGES_DICT.has_key(value):
+            return settings.LANGUAGES_DICT[value]
+        else:
+            return "Uknown language: "+value
+
+def userlink_filter(uname, path):
+    (i18n_base, ctx, lang_suffix) = parse_url_path(path)
+    return userlink(uname, i18n_base=i18n_base,lang_suffix=lang_suffix)
+
+class GhmarkupNode(template.Node):
+    def __init__(self, nodelist):
+        self.nodelist = nodelist
+    def render(self, context):
+        output = self.nodelist.render(context)
+        return ghmarkup(output, context['url_path']).encode('utf-8')
+
+def ghmarkup_tag(parser, token):
+    nodelist = parser.parse(('endghmarkuptag',))
+    parser.delete_first_token()
+    return GhmarkupNode(nodelist)
hunk ./app/templatetags/ghmarkup.py 344
+register.filter('translatelink', translatelink)
+register.filter('prettylang', prettylang)
+register.filter('userlink', userlink_filter)
+register.tag('ghmarkuptag',ghmarkup_tag)
hunk ./app/views.py 10
+from ghestalt.i18n.utils import *
hunk ./app/views.py 19
-	prefix = titleprefs[ltitle[0]]
+	prefix = _(titleprefs[ltitle[0]])
hunk ./app/views.py 22
-	suffix = ' discussion'
+	suffix = _(' discussion')
hunk ./app/views.py 24
+    ltitle[-1] = i18n_baselang(ltitle[-1])
hunk ./app/views.py 27
-def wiki_showpage(request, page):
+def wiki_homepage(request):
+    return HttpResponseRedirect(i18n_site_base(request)+'/wiki/HomePage'+i18n_wiki_suffix(request))
+
+def wiki_showpage(request, page, origwhat=None):
hunk ./app/views.py 35
+        if i18n_baselang(what) != what:
+            return wiki_showpage(request,i18n_baselang(page),origwhat=what)
+        if origwhat:
+            what = origwhat
hunk ./app/views.py 41
-    return render_to_response('wiki.html',{'title':wikititle(what), 'log':log},
+    if i18n_lang_suffix(what)[1:] in settings.LANGUAGES_BIDI:
+        content_bidi = True
+    else:
+        content_bidi = False
+    all_langs = map(lambda x: x['what'],Log.objects.filter(what__startswith=i18n_baselang(what)).values('what').distinct())
+    all_langs = filter(lambda x: x.rsplit('_',1)[0]==i18n_baselang(what),all_langs)
+    all_langs.sort()
+    trans_target = None
+    trans_source = what
+    if i18n_baselang(what) not in all_langs:
+        trans_target = i18n_baselang(what)
+    try:
+        if i18n_baselang(what)+'_'+request.session['otro_lang'] not in all_langs:
+            trans_target = i18n_baselang(what)+'_'+request.session['otro_lang']
+    except KeyError:
+        pass
+    if origwhat:
+        trans_target = origwhat
+        what = origwhat
+    return render_to_response('wiki.html',{'title':wikititle(page), 'log':log, 'origwhat':origwhat, 'what':what, 'all_langs':all_langs, 'trans_target':trans_target, 'trans_source':trans_source, 'no_title':log.ldata.startswith('=='),'CONTENT_BIDI': content_bidi},
hunk ./app/views.py 68
-    return render_to_response('wiki.html',{'title':wikititle(log.what), 'log':log},
+    return render_to_response('wiki.html',{'title':wikititle(log.what), 'log':log, 'what':log.what},
hunk ./app/views.py 87
+class NewPageForm(Form):
+    page_name = CharField(label=_('Page name'),max_length=30,required=False)
+    language = ChoiceField(label=_('Language'),choices=settings.LANGUAGES)
+    def clean(self):
+        return self.clean_data
+    
+def wiki_new(request):
+    if request.POST:
+        form = NewPageForm(request.POST)
+        if form.is_valid():
+            page_name = form.clean_data.get('page_name')
+            language = form.clean_data.get('language')
+            if language!=settings.LANGUAGE_CODE[:2]:
+                suffix = '_'+language
+            else:
+                suffix = ''
+            return HttpResponseRedirect(i18n_site_base(request)+'/edit/wiki/'+page_name+suffix)
+    else:
+        form = NewPageForm({'language':request.LANGUAGE_CODE[:2]})
+    return render_to_response('newpage.html',{'form':form},
+                              RequestContext(request))
+
hunk ./app/views.py 110
-    ldata = CharField(widget=Textarea(attrs={'rows': 24, 'cols': 80}), label="Text")
+    ldata = CharField(widget=Textarea(attrs={'rows': 24, 'cols': 80}), label=_("Text"))
hunk ./app/views.py 123
-            if request.POST['submit']=='Preview':
-                return render_to_response('edit.html',{'form': form, 'title':wikititle(what), 'mtime':'now', 'muser':'me', 'preview': form.clean_data.get('ldata')},
+            if '_preview' in request.POST:
+                if i18n_lang_suffix(what)[1:] in settings.LANGUAGES_BIDI:
+                    content_bidi = True
+                else:
+                    content_bidi = False
+                return render_to_response('edit.html',{'form': form, 'title':wikititle(what), 'mtime':'now', 'muser':'me', 'preview': form.clean_data.get('ldata'), 'what':what,'CONTENT_BIDI': content_bidi },
hunk ./app/views.py 132
-            return HttpResponseRedirect('/' + what)
+            return HttpResponseRedirect(i18n_site_base(request)+'/' + what)
hunk ./app/views.py 134
+        if request.GET.has_key('source'):
+            source = request.GET['source']
+            add_prefixes = True
+        else:
+            source = what
+            add_prefixes = False
hunk ./app/views.py 141
-            log = Log.objects.filter(what=what).latest()
-            form = LogForm({'ldata':log.ldata})
+            log = Log.objects.filter(what=source).latest()
+            trans_message = '\n^^^^^ '+_('Replace caret marked lines with translation')+'\n^ '
+            if add_prefixes:
+                form = LogForm({'ldata':trans_message+log.ldata.replace('\n','\n^ ')+trans_message+'\n'})
+            else:
+                form = LogForm({'ldata':log.ldata})
hunk ./app/views.py 149
-    return render_to_response('edit.html',{'form': form, 'title':wikititle(what), 'mtime':'now', 'muser':'me'},
+    return render_to_response('edit.html',{'form': form, 'title':wikititle(what), 'mtime':'now', 'muser':'me', 'what':what},
hunk ./app/views.py 154
-def show_theorem(request, theorem):
+def show_theorem(request, theorem, origwhat=None):
hunk ./app/views.py 170
+            if i18n_baselang(what) != what:
+                return show_theorem(request,i18n_baselang(theorem),origwhat=what)
hunk ./app/views.py 174
+    if origwhat:
+        what = origwhat
+    render_dict['what'] = what
+    render_dict['origwhat'] = origwhat
hunk ./local_settings.py 8
+ENABLE_MAIL = False
+
hunk ./settings.py 4
+gettext = lambda x: x  # dummy gettext enables marking translation strings
hunk ./settings.py 10
-SITE_NAME = 'Ghestalt'
+SITE_NAME = gettext('Ghestalt')
hunk ./settings.py 61
-    'django.template.loaders.filesystem.load_template_source',
-    'django.template.loaders.app_directories.load_template_source',
+#    'django.template.loaders.filesystem.load_template_source',
+#    'django.template.loaders.app_directories.load_template_source',
+    'ghestalt.template.loaders.i18n_filesystem.load_template_source',
+    'ghestalt.template.loaders.i18n_app_directories.load_template_source',
hunk ./settings.py 71
+    'ghestalt.middleware.localeurl.LocaleURLMiddleware',
hunk ./static/css/style.css 104
-.productImage {
-border:solid 1px silver;
-padding:5px;
-float: left;
-margin-top: 10px;
-margin-left: 10px;
-margin-right: 10px;
-margin-bottom:2px;
-}
+.productImage {
+border:solid 1px silver;
+padding:5px;
+float: left;
+margin-top: 10px;
+margin-left: 10px;
+margin-right: 10px;
+margin-bottom:2px;
+}
hunk ./static/css/style.css 114
-.productImage p {
-   text-align: center;
-   font-size: 10pt;
+.productImage p {
+   text-align: center;
+   font-size: 10pt;
hunk ./static/css/style.css 217
+DIV.new {text-decoration: none; color: red}
hunk ./urls.py 3
+from ghestalt.i18n.utils import *
hunk ./urls.py 6
+    (r'^intl/\w\w(?P<url>/intl/.*)$', 'django.views.generic.simple.direct_to_template',
+     {'template':'site_404.html','message':'Page seems unavailable. Please check URL browser is pointing at.'}),
+    (r'^intl/\w\w/', include('ghestalt.urls')),
+    (r'^i18ninfo/', 'ghestalt.i18n.views.i18ninfo'),
+    (r'^intl', 'ghestalt.i18n.views.i18n_chooselang'),
hunk ./urls.py 13
+    (r'^$','ghestalt.i18n.views.redirectroot'),
hunk ./urls.py 17
+    (r'^wiki/$',                            'wiki_homepage'),
hunk ./urls.py 19
+    (r'^wiki/NewPage$',                     'wiki_new'),
hunk ./urls.py 29
-urlpatterns += patterns('django.views.generic',
-    (r'^wiki/$','simple.redirect_to',{'url':'/wiki/HomePage'}),
-)
-
hunk ./urls.py 33
+    (r'^accounts/profile/$',                  'accounts.info'),
+    (r'^accounts/edit/$',                  'accounts.edit'),
hunk ./urls.py 39
-    (r'^$','simple.direct_to_template',{'template':'intro.html'}),
}
