team4alfanous team mailing list archive
-
team4alfanous team
-
Mailing list archive
-
Message #00339
[Branch ~team4alfanous/alfanous/alfanous-git] Rev 532: Improve the localization of WUI to RTL languages, specially Arabic
------------------------------------------------------------
revno: 532
committer: Assem Chelli <assem.ch@xxxxxxxxx>
timestamp: Tue 2013-01-08 12:00:30 +0100
message:
Improve the localization of WUI to RTL languages, specially Arabic
modified:
src/alfanous-django/templates/aya_search.html
src/alfanous-django/templates/base.html
src/alfanous-django/templates/results.html
src/alfanous-django/wui/views.py
--
lp:alfanous
https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git
Your team Alfanous team is subscribed to branch lp:alfanous.
To unsubscribe from this branch go to https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git/+edit-subscription
=== modified file 'src/alfanous-django/templates/aya_search.html'
--- src/alfanous-django/templates/aya_search.html 2013-01-07 20:09:13 +0000
+++ src/alfanous-django/templates/aya_search.html 2013-01-08 11:00:30 +0000
@@ -3,7 +3,7 @@
{% load custom_filters %}
{% block options %}
-<div class="options" dir="{{ bidi }}">
+<div class="options" dir="{{ bidi.direction }}">
<input type="checkbox" name="fuzzy" value="True" {{ params.fuzzy|yesno:"checked," }} />
<span class="xtitle">{{ _("Fuzzy search") }} </span>
<input type="checkbox" name="vocalized" value="False" {{ params.vocalized|yesno:"checked," }} />
@@ -18,7 +18,7 @@
{% block help_panel %}
<div id="help" class="modal" style="width: 675px; text-align: left;">
<h2>{{ _("Help") }}</h2>
- <table dir="{{ bidi }}" style=" border: 2px dashed gray;margin: 5px;width: 672px;">
+ <table dir="{{ bidi.direction }}" style=" border: 2px dashed gray;margin: 5px;width: 672px;">
<tbody>
<tr>
@@ -87,7 +87,7 @@
{% endblock %}
{% block translations_panel %}
- <span class="xtitle"> {{ _("Translation:") }} :</span>
+ <span class="xtitle"> {{ _("Translation") }} :</span>
<select id="translation" class="styled" name="translation">
<option value="en.transliteration">{{ _("Default") }}</option>
<option value="None" {% ifequal params.translation "None" %}selected{% endifequal %}>{{ _("No translation") }}</option>
@@ -119,7 +119,7 @@
{% with results.search.interval.page|add:"-1"|stringformat:"s" as prev_page %}
<a class='no_decoration' href='?{% build_search_link params params.query prev_page False%}'>
{% endwith %}
- <img src='/static/images/prev{{ image_extension }}.gif' alt='Previous page' title = 'Previous page' />
+ <img src='/static/images/prev{{ bidi.image_extension }}.gif' alt='{{ _("Previous page") }}' title = '{{ _("Previous page") }}' />
</a>
{% endif %}
<div style=' display:inline-block; position:relative; top:-8px;'>
@@ -144,7 +144,7 @@
{% with results.search.interval.page|add:"+1"|stringformat:"s" as next_page %}
<a class='no_decoration' href='?{% build_search_link params params.query next_page False%}'>
{% endwith %}
- <img src='/static/images/next{{ image_extension }}.gif' alt='Next page' title = 'Next page' /></a>
+ <img src='/static/images/next{{ bidi.image_extension }}.gif' alt='{{ _("Next page") }}' title = '{{ _("Next page") }}' /></a>
{% endif %}
</div>
=== modified file 'src/alfanous-django/templates/base.html'
--- src/alfanous-django/templates/base.html 2013-01-07 23:05:46 +0000
+++ src/alfanous-django/templates/base.html 2013-01-08 11:00:30 +0000
@@ -216,14 +216,14 @@
{# <li class="menuitem"><a href="/dream/">{{ _("Dreams") }}</a></li> #}
{# <li class="menuitem"><a href="/poem/">{{ _("Poems") }}</a></li> #}
-<nav>
+<nav id="language_menu">
<ul class = "right">
- <li class="menuitem"><a href="#"> {{ language_local_name }} ↓</a>
+ <li class="menuitem"><a href="#"> {{ language.name_local }} ↓</a>
<ul class = "right">
- {% for language in available_languages %}
+ {% for available_language in available_languages %}
<li class="listItem">
- {% ifequal language.0 language_code %}<span >{{ language.1 }}</span>
- {% else %} <a href="/{{ language.0 }}/">{{ language.1 }}</a>
+ {% ifequal available_language.0 language.code %}<span >{{ available_language.1 }}</span>
+ {% else %} <a href="/{{ available_language.0 }}/">{{ available_language.1 }}</a>
{% endifequal %}
</li><br/>
{% endfor %}
@@ -241,12 +241,12 @@
<div>
<table>
<tr>
- <td colspan="4" style="background:transparent url(/static/images/logo{{ image_extension }}.png); width:385px; height:200px;"> </td>
+ <td colspan="4" style="background:transparent url(/static/images/logo{{ bidi.image_extension }}.png); width:385px; height:200px;"> </td>
</tr>
<tr>
<td style="background:url(/static/images/main_table_02.png) no-repeat;width:50px;height:26px"> </td>
<td style="background:url(/static/images/main_table_03.png) no-repeat;width:259px;height:26px">
- <input style="direction: {{ bidi }} ; text-align:{{ align }}" id="search_box" name="query" class="enter keyboardInput" type="text" value="{{ params.query }}" />
+ <input style="direction: {{ bidi.direction }} ; text-align:{{ bidi.align }}" id="search_box" name="query" class="enter keyboardInput" type="text" value="{{ params.query }}" />
</td>
<td style="background:url(/static/images/main_table_04.png) repeat scroll 0 0 transparent;width:62;height:26;text-align:right;">
<a class="button" href="" onclick="$('#form').submit(); return false;">{{ _("search") }}</a>
@@ -316,7 +316,7 @@
{% endblock %}
<br />
-<div class="xdrops_continer" style="direction:{{ bidi }}; text-align:{{ align_inverse }}; width: 342px;">
+<div class="xdrops_continer" style="direction:{{ bidi.direction }}; text-align:{{ bidi.align_inverse }}; width: 342px;">
<span class="xtitle">{{ _("View") }} :</span>
<select id="view" class="styled" name="view" >
<option value="default" {% ifequal params.view "default" %}selected{% endifequal %}>{{ _("Default") }}</option>
@@ -358,14 +358,14 @@
<!--abdellah-->
-<div id="search_result" style="direction:{{ bidi }}; width:800px">
+<div id="search_result" style="direction:{{ bidi.direction }}; width:800px">
<!-- assem: search_result_django_static -->
{% block results %} {% endblock results %}
</div>
</div>
</div>
-<div id="down" class="modal" style="text-align: {{ align }};">
+<div id="down" class="modal" style="text-align: {{ bidi.align }};">
<h2 style='padding:0 0 0px 0'><img alt="download" src="/static/images/Download.png">{{ _("Download") }}</h2><br/>
<strong> {{ _("English desktop release 0.4") }}:
<a class="name" title="Click to download alfanousDesktop-win0.4r20.exe" href="http://sourceforge.net/projects/alfanous/files/Interfaces/AlfanousDesktop/0.4.20/alfanousDesktop-win0.4r20.exe/download">{{ _("Windows") }}</a>
=== modified file 'src/alfanous-django/templates/results.html'
--- src/alfanous-django/templates/results.html 2013-01-07 20:27:45 +0000
+++ src/alfanous-django/templates/results.html 2013-01-08 11:00:30 +0000
@@ -9,7 +9,7 @@
{% block results %}
{% if results.error.code == 0 %}
- <div id="search_result_static" style="direction:{{ bidi }}; width:800px">
+ <div id="search_result_static" style="direction:{{ bidi.direction }}; width:800px">
<br /><br /><br />
<span class='xbre'> {{ _("Search results") }}</span>
<br /><br />
@@ -17,10 +17,10 @@
</div>
<!-- Suggestions-->
{% if suggestions.error.code == 0 and suggestions.suggest %}
- <div id='suggestions' style=" text-align:{{ align }}" >
+ <div id='suggestions' style=" text-align:{{ bidi.align }}" >
<h2 style='font-size:16pt; color:#ff0000;'>{{ _("Suggestions:") }}
{% for suggestion_key, suggestion_item in suggestions.suggest.items %}
- <p dir='{{ bidi }}' >
+ <p dir='{{ bidi.direction }}' >
<div class='word_details'>
<span style=' font-size:14pt; color:#00aa00;'> {{ forloop.counter }}. </span>
<div class='details_label word_info0'> {{ _("word") }} | {{ suggestion_key }} </div>
@@ -37,7 +37,7 @@
{% if results.search.interval.total %}
{% if results.search.words.global.nb_words %}
<!-- Words list -->
- <div id='search_words' style=" text-align:{{ align }}" >
+ <div id='search_words' style=" text-align:{{ bidi.align }}" >
<h2 style='font-size:16pt; color:#ff0000;'>
Words:
<div class='details_label word_count'>
@@ -62,7 +62,7 @@
<div class='details_label word_vocalization_nb'> {{ _("vocalizations") }} | {{ wordstat.nb_vocalizations }} </div>
{% for vocalization in wordstat.vocalizations %}
- {% with "aya_:"|add:vocalization|add:"" as new_query %}
+ {% with bidi.fields.aya_|add:":"|add:vocalization|add:"" as new_query %}
<a class='no_decoration' href="?{% build_search_link params new_query 1 False %}">
{% endwith %}
<div class='details_label word_vocalization clickable quran'> {{ vocalization }} </div></a>
@@ -143,7 +143,7 @@
{% for ayaresult_id, ayaresult_content in results.search.ayas.items %}
<fieldset class='main_re_item'>
- <legend class='main_re_item_title' style='font-size:14pt; ' dir='{{ bidi }}'>
+ <legend class='main_re_item_title' style='font-size:14pt; ' dir='{{ bidi.direction }}'>
<span align='left' style='color:#0000ff;'>
{{ _("Result n°") }} <b> {{ ayaresult_id }} </b>
</span>
@@ -161,12 +161,12 @@
{% if ayaresult_content.sura %}
<div class='sura_details'>
- {% with 'sura:"'|add:ayaresult_content.sura.name|add:'"' as new_query %}
+ {% with bidi.fields.sura|add:':"'|add:ayaresult_content.sura.name|add:'"' as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 True %}'>
{% endwith %}
<div class='details_label sura_info0 clickable filter'> {{ _("Sura") }} | {{ ayaresult_content.sura.name }} </div></a>
<div class='details_label sura_ord0'> {{ _("n°") }} | {{ ayaresult_content.sura.id }} </div>
- {% with 'sura_type:'|add:ayaresult_content.sura.type|add:'' as new_query %}
+ {% with bidi.fields.sura_type|add:':'|add:ayaresult_content.sura.type|add:'' as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 True %}'>
{% endwith %}
<div class='details_label sura_info1 clickable filter'> {{ _("type") }} | {{ ayaresult_content.sura.type }} </div></a>
@@ -197,7 +197,7 @@
<span dir="ltr" class='prev_aya'>
{% with ayaresult_content.aya.prev_aya.id|stringformat:"s" as prev_aya_id %}
- {% with 'sura:"'|add:ayaresult_content.aya.prev_aya.sura|add:'" + aya_id:'|add:prev_aya_id|urlencode as new_query %}
+ {% with bidi.fields.sura|add:':"'|add:ayaresult_content.aya.prev_aya.sura|add:'" + '|add:bidi.fields.aya_id|add:':'|add:prev_aya_id|urlencode as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 False %}'>
{% endwith %}
{% endwith %}
@@ -234,7 +234,7 @@
<span dir="rtl" class='main_aya'>
{% with ayaresult_content.aya.id|stringformat:"s" as aya_id %}
- {% with 'sura:"'|add:ayaresult_content.identifier.sura_name|add:'" + aya_id:'|add:aya_id|urlencode as new_query %}
+ {% with bidi.fields.sura|add:':"'|add:ayaresult_content.identifier.sura_name|add:'" + '|add:bidi.fields.aya_id|add:':'|add:aya_id|urlencode as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 False %}'>
{% endwith %}
{% endwith %}
@@ -261,7 +261,7 @@
<span dir="ltr" class='next_aya'>
{% with ayaresult_content.aya.next_aya.id|stringformat:"s" as next_aya_id %}
- {% with 'sura:"'|add:ayaresult_content.aya.next_aya.sura|add:'" + aya_id:'|add:next_aya_id|urlencode as new_query %}
+ {% with bidi.fields.sura|add:':"'|add:ayaresult_content.aya.next_aya.sura|add:'" + '|add:bidi.fields.aya_id|add:':'|add:next_aya_id|urlencode as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 False %}'>
{% endwith %}
{% endwith %}
@@ -289,21 +289,21 @@
<span style=' color:#808080;'>
{% if ayaresult_content.theme.chapter %}
{{ _("Chapter") }} :
- {% with 'chapter:"'|add:ayaresult_content.theme.chapter|add:'"' as new_query %}
+ {% with bidi.fields.chapter|add:':"'|add:ayaresult_content.theme.chapter|add:'"' as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 False %}'>
{% endwith %}
<b> {{ ayaresult_content.theme.chapter }} </b></a>
{% endif %}
{% if ayaresult_content.theme.topic %}
{{ _("Topic") }} :
- {% with 'topic:"'|add:ayaresult_content.theme.topic|add:'"' as new_query %}
+ {% with bidi.fields.topic|add:':"'|add:ayaresult_content.theme.topic|add:'"' as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 False %}'>
{% endwith %}
<b> {{ ayaresult_content.theme.topic }} </b></a>
{% endif %}
{% if ayaresult_content.theme.subtopic %}
{{ _("Subtopic") }}:
- {% with 'subtopic:"'|add:ayaresult_content.theme.subtopic|add:'"' as new_query %}
+ {% with bidi.fields.subtopic|add:':"'|add:ayaresult_content.theme.subtopic|add:'"' as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 False %}'>
{% endwith %}
<b> {{ ayaresult_content.theme.subtopic }} </b></a>
@@ -316,19 +316,19 @@
<div class='aya_details'>
{% if ayaresult_content.stat %}
{% with ayaresult_content.stat.words|stringformat:"s" as stat_words %}
- {% with 'a_w:'|add:stat_words as new_query %}
+ {% with bidi.fields.a_w|add:':'|add:stat_words as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 False %}'>
{% endwith %}
{% endwith %}
<div class='details_label aya_stat0 clickable'> {{ _("words") }} | {{ ayaresult_content.stat.words }} </div></a>
{% with ayaresult_content.stat.letters|stringformat:"s" as stat_letters %}
- {% with 'a_l:'|add:stat_letters as new_query %}
+ {% with bidi.fields.a_l|add:':'|add:stat_letters as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 False %}'>
{% endwith %}
{% endwith %}
<div class='details_label aya_stat1 clickable'> {{ _("letters") }} | {{ ayaresult_content.stat.letters }} </div></a>
{% with ayaresult_content.stat.godnames|stringformat:"s" as stat_godnames %}
- {% with 'a_g:'|add:stat_godnames as new_query %}
+ {% with bidi.fields.a_g|add:':'|add:stat_godnames as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 False %}'>
{% endwith %}
{% endwith %}
@@ -336,20 +336,20 @@
{% endif %}
{% if ayaresult_content.position %}
{% with ayaresult_content.position.manzil|stringformat:"s" as position_manzil %}
- {% with 'manzil:'|add:position_manzil as new_query %}
+ {% with bidi.fields.manzil|add:':'|add:position_manzil as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 True%}'>
{% endwith %}
{% endwith %}
<div class='details_label aya_pos0 clickable filter'> {{ _("manzil") }} | {{ ayaresult_content.position.manzil }} </div></a>
{% with ayaresult_content.position.hizb|stringformat:"s" as position_hizb %}
- {% with 'hizb:'|add:position_hizb as new_query %}
+ {% with bidi.fields.hizb|add:':'|add:position_hizb as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 True%}'>
{% endwith %}
{% endwith %}
<div class='details_label aya_pos1 clickable filter'> {{ _("hizb") }} | {{ ayaresult_content.position.hizb }} </div></a>
<div class='details_label aya_pos2'> {{ _("quart") }} | {{ ayaresult_content.position.rub|add:"+1" }} </div>
{% with ayaresult_content.position.page|stringformat:"s" as position_page %}
- {% with 'page:'|add:position_page as new_query %}
+ {% with bidi.fields.page|add:':'|add:position_page as new_query %}
<a class='no_decoration' href='?{% build_search_link params new_query 1 True%}'>
{% endwith %}
{% endwith %}
=== modified file 'src/alfanous-django/wui/views.py'
--- src/alfanous-django/wui/views.py 2013-01-07 20:47:14 +0000
+++ src/alfanous-django/wui/views.py 2013-01-08 11:00:30 +0000
@@ -106,27 +106,40 @@
request.LANGUAGE_CODE = translation.get_language()
+ # language direction properties
+ bidi_val = language_info['bidi']
+ fields_mapping_en_ar = raw_show["show"]["fields_reverse"]
+ fields_mapping_en_en = { k:k for k in fields_mapping_en_ar.keys() }
+ bidi_properties = {
+ False : {
+ "val": bidi_val,
+ "direction": "ltr",
+ "align": "left",
+ "align_inverse": "right",
+ "image_extension": "_en",
+ "fields": fields_mapping_en_en
+ },
+ True : {
+ "val": bidi_val,
+ "direction": "rtl",
+ "align": "right",
+ "align_inverse": "left",
+ "image_extension": "_ar",
+ "fields": fields_mapping_en_ar
+ }
+ }
+
mytemplate = unit + '_search.html'
return render_to_response( mytemplate ,
{
'current_path': request.get_full_path(),
- "bidi": "rtl" if language_info['bidi']
- else "ltr",
- "language_local_name": language_info['name_local'],
- "language_code": language_info['code'],
+ "bidi":bidi_properties[bidi_val],
+ "language": language_info,
"available_languages": available_languages,
- "align": "right" if language_info['bidi']
- else "left",
- "align_inverse": "left" if language_info['bidi']
- else "right",
- "image_extension": "_ar" if language_info['bidi']
- else "_en",
-
"params": search_params,
"results": raw_search,
"suggestions": raw_suggest,
"info": raw_show
-
}
)