From: Radek Czajka Date: Wed, 5 Feb 2014 10:59:50 +0000 (+0100) Subject: Translatable chunks. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/e6fc1b86fcdb4f99c00d4218fcaa5eab6f64c4cb?hp=e22bc1d420f3fa0caea45f7e065c5b376756ee01 Translatable chunks. --- diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo index d3585a52a..66ae6880c 100644 Binary files a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo and b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo differ diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.po b/apps/catalogue/locale/pl/LC_MESSAGES/django.po index 45c6f0cd4..5eb177911 100644 --- a/apps/catalogue/locale/pl/LC_MESSAGES/django.po +++ b/apps/catalogue/locale/pl/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-12-19 12:45+0100\n" -"PO-Revision-Date: 2013-12-19 12:46+0100\n" +"POT-Creation-Date: 2014-02-05 11:21+0100\n" +"PO-Revision-Date: 2014-02-05 11:21+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" @@ -98,7 +98,7 @@ msgstr "Błąd podczas importowania pliku: %r" msgid "Download custom PDF" msgstr "Stwórz własny PDF" -#: views.py:633 templates/catalogue/book_short.html:103 +#: views.py:633 templates/catalogue/book_short.html:97 #: templates/catalogue/book_wide.html:63 msgid "Download" msgstr "Pobierz" @@ -125,7 +125,7 @@ msgstr "slug" msgid "language code" msgstr "Kod języka" -#: models/book.py:36 models/book.py:161 models/collection.py:13 +#: models/book.py:36 models/book.py:164 models/collection.py:13 #: models/tag.py:37 models/tag.py:94 msgid "description" msgstr "opis" @@ -147,25 +147,29 @@ msgstr "dodatkowe informacje" msgid "cover" msgstr "okładka" -#: models/book.py:67 models/collection.py:18 models/tag.py:22 +#: models/book.py:48 +msgid "cover thumbnail" +msgstr "podgląd okładki" + +#: models/book.py:70 models/collection.py:18 models/tag.py:22 msgid "book" msgstr "książka" -#: models/book.py:68 +#: models/book.py:71 msgid "books" msgstr "książki" -#: models/book.py:259 +#: models/book.py:262 #, python-format msgid "Book \"%s\" does not exist." msgstr "Utwór \"%s\" nie istnieje." -#: models/book.py:273 +#: models/book.py:276 #, python-format msgid "Book %s already exists" msgstr "Książka %s już istnieje" -#: models/book.py:620 models/bookmedia.py:23 +#: models/book.py:625 models/bookmedia.py:23 #, python-format msgid "%s file" msgstr "plik %s" @@ -262,30 +266,25 @@ msgstr "" "Tagi typu książka nie mogą mieć ustawionych linków. Ustaw je bezpośrednio " "dla książki, zamiast dla jej tagu." -#: templates/catalogue/audiobook_list.html:7 -#: templates/catalogue/audiobook_list.html:16 +#: templates/catalogue/audiobook_list.html:8 +#: templates/catalogue/audiobook_list.html:17 msgid "Listing of all audiobooks" msgstr "Spis wszystkich audiobooków" -#: templates/catalogue/audiobook_list.html:12 +#: templates/catalogue/audiobook_list.html:13 msgid "Latest MP3 audiobooks" msgstr "Ostatnio dodane audiobooki w formacie MP3" -#: templates/catalogue/audiobook_list.html:13 +#: templates/catalogue/audiobook_list.html:14 msgid "Latest Ogg Vorbis audiobooks" msgstr "Ostatnio dodane audiobooki w formacie Ogg Vorbis" -#: templates/catalogue/audiobook_list.html:19 -msgid "" -"Audioteka lektur szkolnych fundacji Nowoczesna Polska.\n" -"Możecie z niej korzystać bezpłatnie i bez ograniczeń.\n" -"Audiobooki nagrywają znani aktorzy, wśród nich Danuta Stenka i Jan Peszek." -msgstr "" -"Audioteka lektur szkolnych fundacji Nowoczesna Polska.\n" -"Możecie z niej korzystać bezpłatnie i bez ograniczeń.\n" -"Audiobooki nagrywają znani aktorzy, wśród nich Danuta Stenka i Jan Peszek." - #: templates/catalogue/book_detail.html:21 +#: templates/catalogue/book_text.html:20 +msgid "Other versions" +msgstr "Inne wersje" + +#: templates/catalogue/book_detail.html:29 #: templates/catalogue/tagged_object_list.html:74 #: templates/catalogue/tagged_object_list.html:109 msgid "See also" @@ -340,126 +339,115 @@ msgstr "Publikację ufundowali i ufundowały:" msgid "Cover image by:" msgstr "Ilustracja na okładce:" -#: templates/catalogue/book_list.html:7 templates/catalogue/book_list.html:10 +#: templates/catalogue/book_list.html:8 templates/catalogue/book_list.html:11 +#: templates/catalogue/picture_list.html:8 +#: templates/catalogue/picture_list.html:10 msgid "Listing of all works" msgstr "Spis wszystkich utworów" -#: templates/catalogue/book_list.html:21 +#: templates/catalogue/book_list.html:24 msgid "Table of Content" msgstr "Spis treści" -#: templates/catalogue/book_list.html:31 +#: templates/catalogue/book_list.html:34 msgid "↑ top ↑" msgstr "↑ góra ↑" -#: templates/catalogue/book_short.html:61 +#: templates/catalogue/book_short.html:55 #: templates/catalogue/picture_detail.html:54 msgid "Epoch" msgstr "Epoka" -#: templates/catalogue/book_short.html:69 +#: templates/catalogue/book_short.html:63 #: templates/catalogue/picture_detail.html:60 msgid "Kind" msgstr "Rodzaj" -#: templates/catalogue/book_short.html:77 +#: templates/catalogue/book_short.html:71 msgid "Genre" msgstr "Gatunek" -#: templates/catalogue/book_short.html:86 +#: templates/catalogue/book_short.html:80 msgid "Language" msgstr "Język" -#: templates/catalogue/book_short.html:99 +#: templates/catalogue/book_short.html:93 msgid "Read online" msgstr "Czytaj online" -#: templates/catalogue/book_short.html:106 +#: templates/catalogue/book_short.html:100 msgid "to print" msgstr "do druku" -#: templates/catalogue/book_short.html:109 +#: templates/catalogue/book_short.html:103 msgid "for an e-book reader" msgstr "na czytnik e-booków" -#: templates/catalogue/book_short.html:112 +#: templates/catalogue/book_short.html:106 msgid "for Kindle" msgstr "na Kindle" -#: templates/catalogue/book_short.html:115 +#: templates/catalogue/book_short.html:109 msgid "FictionBook" msgstr "FictionBook" -#: templates/catalogue/book_short.html:118 +#: templates/catalogue/book_short.html:112 msgid "for advanced usage" msgstr "do zadań specjalnych" -#: templates/catalogue/book_short.html:124 +#: templates/catalogue/book_short.html:118 msgid "Listen" msgstr "Słuchaj" -#: templates/catalogue/book_text.html:10 templates/catalogue/player.html:11 -msgid "Wolne Lektury" -msgstr "Wolne Lektury" - -#: templates/catalogue/book_text.html:34 -msgid "Other versions" -msgstr "Inne wersje" - -#: templates/catalogue/book_text.html:40 +#: templates/catalogue/book_text.html:26 msgid "Table of contents" msgstr "Spis treści" -#: templates/catalogue/book_text.html:44 templatetags/catalogue_tags.py:424 +#: templates/catalogue/book_text.html:30 templatetags/catalogue_tags.py:421 msgid "Themes" msgstr "Motywy" -#: templates/catalogue/book_text.html:48 -#: templates/catalogue/book_text.html:100 +#: templates/catalogue/book_text.html:34 templates/catalogue/book_text.html:91 msgid "Settings" msgstr "Ustawienia" -#: templates/catalogue/book_text.html:52 +#: templates/catalogue/book_text.html:38 msgid "Edit. note" msgstr "Nota red." -#: templates/catalogue/book_text.html:56 +#: templates/catalogue/book_text.html:42 msgid "Infobox" msgstr "Informacje" -#: templates/catalogue/book_text.html:68 -#: templates/catalogue/book_text.html:114 +#: templates/catalogue/book_text.html:56 +#: templates/catalogue/viewer_base.html:53 msgid "Close" msgstr "Zamknij" -#: templates/catalogue/book_text.html:69 +#: templates/catalogue/book_text.html:57 msgid "Please wait..." msgstr "Proszę czekać…" -#: templates/catalogue/book_text.html:82 +#: templates/catalogue/book_text.html:73 msgid "Other versions of the book" msgstr "Inne wersje utworu" -#: templates/catalogue/book_text.html:83 +#: templates/catalogue/book_text.html:74 msgid "Close the other version" msgstr "Zamknij drugą wersję" -#: templates/catalogue/book_text.html:101 +#: templates/catalogue/book_text.html:92 msgid "Display line numbers" msgstr "Wyświetlaj numerację" -#: templates/catalogue/book_text.html:102 +#: templates/catalogue/book_text.html:93 msgid "Display themes" msgstr "Wyświetlaj motywy" -#: templates/catalogue/book_text.html:103 +#: templates/catalogue/book_text.html:94 msgid "Display footnotes" msgstr "Wyświetlaj przypisy" -#: templates/catalogue/book_text.html:116 -msgid "Loading" -msgstr "Ładowanie" - #: templates/catalogue/book_wide.html:22 #: templates/catalogue/tagged_object_list.html:60 msgid "Motifs and themes" @@ -517,28 +505,28 @@ msgstr "Pobierz katalog w formacie PDF." #: templates/catalogue/catalogue.html:19 #: templates/catalogue/search_multiple_hits.html:17 #: templates/catalogue/tagged_object_list.html:26 -#: templatetags/catalogue_tags.py:420 +#: templatetags/catalogue_tags.py:417 msgid "Authors" msgstr "Autorzy" #: templates/catalogue/catalogue.html:22 #: templates/catalogue/search_multiple_hits.html:25 #: templates/catalogue/tagged_object_list.html:34 -#: templatetags/catalogue_tags.py:422 +#: templatetags/catalogue_tags.py:419 msgid "Kinds" msgstr "Rodzaje" #: templates/catalogue/catalogue.html:25 #: templates/catalogue/search_multiple_hits.html:33 #: templates/catalogue/tagged_object_list.html:42 -#: templatetags/catalogue_tags.py:421 +#: templatetags/catalogue_tags.py:418 msgid "Genres" msgstr "Gatunki" #: templates/catalogue/catalogue.html:28 #: templates/catalogue/search_multiple_hits.html:41 #: templates/catalogue/tagged_object_list.html:50 -#: templatetags/catalogue_tags.py:423 +#: templatetags/catalogue_tags.py:420 msgid "Epochs" msgstr "Epoki" @@ -550,27 +538,15 @@ msgstr "Motywy i tematy" msgid "Collections" msgstr "Kolekcje" -#: templates/catalogue/daisy_list.html:6 -#: templates/catalogue/daisy_list.html:12 +#: templates/catalogue/daisy_list.html:7 +#: templates/catalogue/daisy_list.html:13 msgid "Listing of all DAISY files" msgstr "Spis wszystkich plików DAISY" -#: templates/catalogue/daisy_list.html:9 +#: templates/catalogue/daisy_list.html:10 msgid "Latest DAISY audiobooks" msgstr "Ostatnio dodane audiobooki w formacie DAISY" -#: templates/catalogue/daisy_list.html:15 -msgid "" -"System DAISY to uznany na całym świecie format udostępniania książek\n" -"dostosowany do potrzeb osób słabowidzących, niewidomych oraz innych osób\n" -"mających trudności z czytaniem. Możecie z nich korzystać bezpłatnie i bez " -"ograniczeń." -msgstr "" -"System DAISY to uznany na całym świecie format udostępniania książek\n" -"dostosowany do potrzeb osób słabowidzących, niewidomych oraz innych osób\n" -"mających trudności z czytaniem. Możecie z nich korzystać bezpłatnie i bez " -"ograniczeń." - #: templates/catalogue/differentiate_tags.html:12 msgid "The criteria are ambiguous. Please select one of the following options:" msgstr "" @@ -610,7 +586,7 @@ msgstr "Audiobooki" msgid "DAISY" msgstr "DAISY" -#: templates/catalogue/menu.html:40 templates/catalogue/tag_list_split.html:14 +#: templates/catalogue/menu.html:40 templates/catalogue/tag_list_split.html:8 msgid "Gallery" msgstr "Galeria" @@ -650,10 +626,9 @@ msgstr "Źródłowy plik XML" msgid "Work's themes " msgstr "Motywy w utworze" -#: templates/catalogue/picture_list.html:8 -#: templates/catalogue/picture_list.html:10 -msgid "Listing of all pictures" -msgstr "Spis wszystkich obrazów" +#: templates/catalogue/player.html:11 templates/catalogue/viewer_base.html:9 +msgid "Wolne Lektury" +msgstr "Wolne Lektury" #: templates/catalogue/player.html:34 msgid "Book's page" @@ -768,7 +743,7 @@ msgstr "" msgid "Sorry! Search query must have at least two characters." msgstr "Przepraszamy! Zapytanie musi zawierać co najmniej dwa znaki." -#: templates/catalogue/tag_list_split.html:5 +#: templates/catalogue/tag_list_split.html:3 msgid "Literature" msgstr "Literatura" @@ -787,6 +762,10 @@ msgstr "w serwisie Lektury.Gazeta.pl" msgid "in Wikipedia" msgstr "w Wikipedii" +#: templates/catalogue/viewer_base.html:55 +msgid "Loading" +msgstr "Ładowanie" + #: templates/catalogue/snippets/custom_pdf_link_li.html:5 msgid "Download a custom PDF" msgstr "Stwórz własny plik PDF" @@ -796,6 +775,29 @@ msgstr "Stwórz własny plik PDF" msgid "Free license" msgstr "Wolna licencja" +#~ msgid "" +#~ "Audioteka lektur szkolnych fundacji Nowoczesna Polska.\n" +#~ "Możecie z niej korzystać bezpłatnie i bez ograniczeń.\n" +#~ "Audiobooki nagrywają znani aktorzy, wśród nich Danuta Stenka i Jan Peszek." +#~ msgstr "" +#~ "Audioteka lektur szkolnych fundacji Nowoczesna Polska.\n" +#~ "Możecie z niej korzystać bezpłatnie i bez ograniczeń.\n" +#~ "Audiobooki nagrywają znani aktorzy, wśród nich Danuta Stenka i Jan Peszek." + +#~ msgid "" +#~ "System DAISY to uznany na całym świecie format udostępniania książek\n" +#~ "dostosowany do potrzeb osób słabowidzących, niewidomych oraz innych osób\n" +#~ "mających trudności z czytaniem. Możecie z nich korzystać bezpłatnie i bez " +#~ "ograniczeń." +#~ msgstr "" +#~ "System DAISY to uznany na całym świecie format udostępniania książek\n" +#~ "dostosowany do potrzeb osób słabowidzących, niewidomych oraz innych osób\n" +#~ "mających trudności z czytaniem. Możecie z nich korzystać bezpłatnie i bez " +#~ "ograniczeń." + +#~ msgid "Listing of all pictures" +#~ msgstr "Spis wszystkich obrazów" + #~ msgid "for a reader" #~ msgstr "na czytnik" diff --git a/apps/catalogue/templates/catalogue/audiobook_list.html b/apps/catalogue/templates/catalogue/audiobook_list.html index 47c804611..1358025a1 100644 --- a/apps/catalogue/templates/catalogue/audiobook_list.html +++ b/apps/catalogue/templates/catalogue/audiobook_list.html @@ -1,6 +1,7 @@ {% extends "catalogue/book_list.html" %} {% load i18n %} {% load catalogue_tags %} +{% load chunks %} {% block bodyid %}book-a-list{% endblock %} @@ -16,7 +17,5 @@ {% block book_list_header %}{% trans "Listing of all audiobooks" %}{% endblock %} {% block book_list_info %} -

{% blocktrans %}Audioteka lektur szkolnych fundacji Nowoczesna Polska. -Możecie z niej korzystać bezpłatnie i bez ograniczeń. -Audiobooki nagrywają znani aktorzy, wśród nich Danuta Stenka i Jan Peszek.{% endblocktrans %}

+{% chunk 'audiobook-list' %} {% endblock %} diff --git a/apps/catalogue/templates/catalogue/book_list.html b/apps/catalogue/templates/catalogue/book_list.html index 00088a58e..260c71fdf 100644 --- a/apps/catalogue/templates/catalogue/book_list.html +++ b/apps/catalogue/templates/catalogue/book_list.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load i18n %} {% load catalogue_tags %} +{% load chunks %} {% block bodyid %}book-a-list{% endblock %} @@ -9,8 +10,10 @@ {% block body %}

{% block book_list_header %}{% trans "Listing of all works" %}{% endblock %}

-
- {% block book_list_info %}{% endblock %} +
+ {% block book_list_info %} + {% chunk 'book-list' %} + {% endblock %}
diff --git a/apps/catalogue/templates/catalogue/daisy_list.html b/apps/catalogue/templates/catalogue/daisy_list.html index fcc25d519..4f570b2b6 100644 --- a/apps/catalogue/templates/catalogue/daisy_list.html +++ b/apps/catalogue/templates/catalogue/daisy_list.html @@ -1,5 +1,6 @@ {% extends "catalogue/book_list.html" %} {% load i18n %} +{% load chunks %} {% block bodyid %}book-a-list{% endblock %} @@ -12,7 +13,5 @@ {% block book_list_header %}{% trans "Listing of all DAISY files" %}{% endblock %} {% block book_list_info %} -

{% blocktrans %}System DAISY to uznany na całym świecie format udostępniania książek -dostosowany do potrzeb osób słabowidzących, niewidomych oraz innych osób -mających trudności z czytaniem. Możecie z nich korzystać bezpłatnie i bez ograniczeń.{% endblocktrans %}

+{% chunk 'daisy-list' %} {% endblock %} diff --git a/apps/chunks/migrations/0001_initial.py b/apps/chunks/migrations/0001_initial.py new file mode 100644 index 000000000..fa51499ae --- /dev/null +++ b/apps/chunks/migrations/0001_initial.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'Chunk' + db.create_table(u'chunks_chunk', ( + ('key', self.gf('django.db.models.fields.CharField')(max_length=255, primary_key=True)), + ('description', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)), + ('content', self.gf('django.db.models.fields.TextField')(blank=True)), + )) + db.send_create_signal(u'chunks', ['Chunk']) + + # Adding model 'Attachment' + db.create_table(u'chunks_attachment', ( + ('key', self.gf('django.db.models.fields.CharField')(max_length=255, primary_key=True)), + ('attachment', self.gf('django.db.models.fields.files.FileField')(max_length=100)), + )) + db.send_create_signal(u'chunks', ['Attachment']) + + + def backwards(self, orm): + # Deleting model 'Chunk' + db.delete_table(u'chunks_chunk') + + # Deleting model 'Attachment' + db.delete_table(u'chunks_attachment') + + + models = { + u'chunks.attachment': { + 'Meta': {'ordering': "('key',)", 'object_name': 'Attachment'}, + 'attachment': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'primary_key': 'True'}) + }, + u'chunks.chunk': { + 'Meta': {'ordering': "('key',)", 'object_name': 'Chunk'}, + 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'primary_key': 'True'}) + } + } + + complete_apps = ['chunks'] \ No newline at end of file diff --git a/apps/chunks/migrations/0002_auto__add_field_chunk_content_de__add_field_chunk_content_en__add_fiel.py b/apps/chunks/migrations/0002_auto__add_field_chunk_content_de__add_field_chunk_content_en__add_fiel.py new file mode 100644 index 000000000..57c893511 --- /dev/null +++ b/apps/chunks/migrations/0002_auto__add_field_chunk_content_de__add_field_chunk_content_en__add_fiel.py @@ -0,0 +1,109 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'Chunk.content_de' + db.add_column(u'chunks_chunk', 'content_de', + self.gf('django.db.models.fields.TextField')(null=True, blank=True), + keep_default=False) + + # Adding field 'Chunk.content_en' + db.add_column(u'chunks_chunk', 'content_en', + self.gf('django.db.models.fields.TextField')(null=True, blank=True), + keep_default=False) + + # Adding field 'Chunk.content_es' + db.add_column(u'chunks_chunk', 'content_es', + self.gf('django.db.models.fields.TextField')(null=True, blank=True), + keep_default=False) + + # Adding field 'Chunk.content_fr' + db.add_column(u'chunks_chunk', 'content_fr', + self.gf('django.db.models.fields.TextField')(null=True, blank=True), + keep_default=False) + + # Adding field 'Chunk.content_it' + db.add_column(u'chunks_chunk', 'content_it', + self.gf('django.db.models.fields.TextField')(null=True, blank=True), + keep_default=False) + + # Adding field 'Chunk.content_lt' + db.add_column(u'chunks_chunk', 'content_lt', + self.gf('django.db.models.fields.TextField')(null=True, blank=True), + keep_default=False) + + # Adding field 'Chunk.content_pl' + db.add_column(u'chunks_chunk', 'content_pl', + self.gf('django.db.models.fields.TextField')(null=True, blank=True), + keep_default=False) + + # Adding field 'Chunk.content_ru' + db.add_column(u'chunks_chunk', 'content_ru', + self.gf('django.db.models.fields.TextField')(null=True, blank=True), + keep_default=False) + + # Adding field 'Chunk.content_uk' + db.add_column(u'chunks_chunk', 'content_uk', + self.gf('django.db.models.fields.TextField')(null=True, blank=True), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'Chunk.content_de' + db.delete_column(u'chunks_chunk', 'content_de') + + # Deleting field 'Chunk.content_en' + db.delete_column(u'chunks_chunk', 'content_en') + + # Deleting field 'Chunk.content_es' + db.delete_column(u'chunks_chunk', 'content_es') + + # Deleting field 'Chunk.content_fr' + db.delete_column(u'chunks_chunk', 'content_fr') + + # Deleting field 'Chunk.content_it' + db.delete_column(u'chunks_chunk', 'content_it') + + # Deleting field 'Chunk.content_lt' + db.delete_column(u'chunks_chunk', 'content_lt') + + # Deleting field 'Chunk.content_pl' + db.delete_column(u'chunks_chunk', 'content_pl') + + # Deleting field 'Chunk.content_ru' + db.delete_column(u'chunks_chunk', 'content_ru') + + # Deleting field 'Chunk.content_uk' + db.delete_column(u'chunks_chunk', 'content_uk') + + + models = { + u'chunks.attachment': { + 'Meta': {'ordering': "('key',)", 'object_name': 'Attachment'}, + 'attachment': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'primary_key': 'True'}) + }, + u'chunks.chunk': { + 'Meta': {'ordering': "('key',)", 'object_name': 'Chunk'}, + 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'content_de': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), + 'content_en': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), + 'content_es': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), + 'content_fr': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), + 'content_it': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), + 'content_lt': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), + 'content_pl': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), + 'content_ru': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), + 'content_uk': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), + 'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'primary_key': 'True'}) + } + } + + complete_apps = ['chunks'] \ No newline at end of file diff --git a/apps/chunks/migrations/__init__.py b/apps/chunks/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/apps/chunks/models.py b/apps/chunks/models.py index ef244eb0b..4ab846b3a 100644 --- a/apps/chunks/models.py +++ b/apps/chunks/models.py @@ -1,6 +1,6 @@ from django.core.cache import cache from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext_lazy as _, get_language class Chunk(models.Model): @@ -20,12 +20,13 @@ class Chunk(models.Model): def __unicode__(self): return self.key - def cache_key(self): - return 'chunk_' + self.key + @staticmethod + def cache_key(key): + return 'chunk/%s/%s' % (key, get_language()) def save(self, *args, **kwargs): ret = super(Chunk, self).save(*args, **kwargs) - cache.delete(self.cache_key()) + cache.delete(self.cache_key(self.key)) return ret diff --git a/apps/chunks/templatetags/chunks.py b/apps/chunks/templatetags/chunks.py index 083c48aa5..cc25df728 100644 --- a/apps/chunks/templatetags/chunks.py +++ b/apps/chunks/templatetags/chunks.py @@ -9,45 +9,23 @@ Chunk = models.get_model('chunks', 'chunk') Attachment = models.get_model('chunks', 'attachment') -def do_get_chunk(parser, token): - # split_contents() knows not to split quoted strings. - tokens = token.split_contents() - if len(tokens) < 2 or len(tokens) > 3: - raise template.TemplateSyntaxError, "%r tag should have either 2 or 3 arguments" % (tokens[0],) - if len(tokens) == 2: - tag_name, key = tokens - cache_time = 0 - if len(tokens) == 3: - tag_name, key, cache_time = tokens - # Check to see if the key is properly double/single quoted - if not (key[0] == key[-1] and key[0] in ('"', "'")): - raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name - # Send key without quotes and caching time - return ChunkNode(key[1:-1], cache_time) - - -class ChunkNode(template.Node): - def __init__(self, key, cache_time=0): - self.key = key - self.cache_time = cache_time - - def render(self, context): - try: - cache_key = 'chunk_' + self.key - c = cache.get(cache_key) - if c is None: - c = Chunk.objects.get(key=self.key) - cache.set(cache_key, c, int(self.cache_time)) - content = c.content - except Chunk.DoesNotExist: - n = Chunk(key=self.key) - n.save() - return '' - return content - -register.tag('chunk', do_get_chunk) +@register.simple_tag +def chunk(key, cache_time=0): + try: + cache_key = Chunk.cache_key(key) + c = cache.get(cache_key) + if c is None: + c = Chunk.objects.get(key=key) + cache.set(cache_key, c, int(cache_time)) + content = c.content + except Chunk.DoesNotExist: + n = Chunk(key=key) + n.save() + return '' + return content +@register.simple_tag def attachment(key, cache_time=0): try: cache_key = 'attachment_' + key @@ -58,6 +36,3 @@ def attachment(key, cache_time=0): return c.attachment.url except Attachment.DoesNotExist: return '' - -register.simple_tag(attachment) - diff --git a/apps/picture/templates/picture/picture_list_thumb.html b/apps/picture/templates/picture/picture_list_thumb.html index 031055681..9684f846c 100644 --- a/apps/picture/templates/picture/picture_list_thumb.html +++ b/apps/picture/templates/picture/picture_list_thumb.html @@ -15,8 +15,8 @@
{% block book_list_info %} -

Galeria zawiera obrazy, rysunki, rzeźby, fotografie pochodzące ze zbiorów Muzeum Narodowego w Warszawie. Każde z dzieł oznaczyliśmy motywami i tematami występującymi w sztuce i w literaturze. Galerię można więc przeglądać w poszukiwaniu ilustracji do tekstów literackich, a także pod kątem określonych przedmiotów i postaci występujących w sztukach wizualnych.

-{% endblock %} + {% chunk 'picture-list' %} + {% endblock %}
{% block book_list_logos %} diff --git a/apps/wolnelektury_core/templates/superbase.html b/apps/wolnelektury_core/templates/superbase.html index 9ee206f57..57dbb1ada 100644 --- a/apps/wolnelektury_core/templates/superbase.html +++ b/apps/wolnelektury_core/templates/superbase.html @@ -3,6 +3,7 @@ {% load cache compressed i18n %} {% load static from staticfiles %} {% load catalogue_tags funding_tags reporting_stats sponsor_tags %} + {% load chunks %} @@ -124,24 +125,9 @@ diff --git a/wolnelektury/translation.py b/wolnelektury/translation.py index c72f654af..95b9dd74f 100644 --- a/wolnelektury/translation.py +++ b/wolnelektury/translation.py @@ -6,6 +6,7 @@ from modeltranslation.translator import translator, TranslationOptions from catalogue.models import Collection, Tag from infopages.models import InfoPage +from chunks.models import Chunk class InfoPageTranslationOptions(TranslationOptions): fields = ('title', 'left_column', 'right_column') @@ -16,7 +17,10 @@ class TagTranslationOptions(TranslationOptions): class CollectionTranslationOptions(TranslationOptions): fields = ('title', 'description') +class ChunkTranslationOptions(TranslationOptions): + fields = ('content',) + translator.register(InfoPage, InfoPageTranslationOptions) translator.register(Tag, TagTranslationOptions) translator.register(Collection, CollectionTranslationOptions) - +translator.register(Chunk, ChunkTranslationOptions)