From 188361b15c8efc117e2f3500e32aa0c60291afd6 Mon Sep 17 00:00:00 2001 From: cirun Date: Wed, 10 May 2023 15:50:40 +0200 Subject: [PATCH 1/4] fix for daterangepicker and add internationalization --- .../assets/js/daterangepicker-module.js | 21 +++-- .../datesearch/assets/js/daterangepicker.js | 2 +- .../datesearch/i18n/ckanext-datesearch.pot | 73 +++++++++++++++++ .../i18n/de/LC_MESSAGES/ckanext-datesearch.mo | Bin 0 -> 1055 bytes .../i18n/de/LC_MESSAGES/ckanext-datesearch.po | 75 ++++++++++++++++++ ckanext/datesearch/plugin.py | 5 +- setup.cfg | 20 +++++ setup.py | 7 ++ 8 files changed, 195 insertions(+), 8 deletions(-) create mode 100644 ckanext/datesearch/i18n/ckanext-datesearch.pot create mode 100644 ckanext/datesearch/i18n/de/LC_MESSAGES/ckanext-datesearch.mo create mode 100644 ckanext/datesearch/i18n/de/LC_MESSAGES/ckanext-datesearch.po create mode 100644 setup.cfg diff --git a/ckanext/datesearch/assets/js/daterangepicker-module.js b/ckanext/datesearch/assets/js/daterangepicker-module.js index 6ca8219..80a8b13 100644 --- a/ckanext/datesearch/assets/js/daterangepicker-module.js +++ b/ckanext/datesearch/assets/js/daterangepicker-module.js @@ -12,15 +12,24 @@ this.ckan.module('daterangepicker-module', function($, _) { $('').appendTo(form); } + const filterBy = { + 'today': this._('Today'), + 'yesterday': this._('Yesterday'), + 'last7': this._('Last 7 Days'), + 'last30': this._('Last 30 Days'), + 'thisMonth': this._('This Month'), + 'lastMonth': this._('Last Month') + }; + // Add a date-range picker widget to the with id #daterange $('input[id="daterange"]').daterangepicker({ ranges: { - 'Today': [moment().startOf('day'), moment().endOf('day')], - 'Yesterday': [moment().subtract('days', 1), moment().subtract('days', 1)], - 'Last 7 Days': [moment().subtract('days', 6), moment()], - 'Last 30 Days': [moment().subtract('days', 29), moment()], - 'This Month': [moment().startOf('month'), moment().endOf('month')], - 'Last Month': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')] + [filterBy.today]: [moment().startOf('day'), moment().endOf('day')], + [filterBy.yesterday]: [moment().subtract('days', 1), moment().subtract('days', 1)], + [filterBy.last7]: [moment().subtract('days', 6), moment()], + [filterBy.last30]: [moment().subtract('days', 29), moment()], + [filterBy.thisMonth]: [moment().startOf('month'), moment().endOf('month')], + [filterBy.lastMonth]: [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')] }, startDate: moment().subtract('days', 29), endDate: moment(), diff --git a/ckanext/datesearch/assets/js/daterangepicker.js b/ckanext/datesearch/assets/js/daterangepicker.js index 17c29d3..d056407 100644 --- a/ckanext/datesearch/assets/js/daterangepicker.js +++ b/ckanext/datesearch/assets/js/daterangepicker.js @@ -40,7 +40,7 @@ fromLabel: "From", toLabel: "To", weekLabel: "W", - customRangeLabel: "Custom Range", + customRangeLabel: ckan.i18n._("Custom Range"), daysOfWeek: moment()._lang._weekdaysMin.slice(), monthNames: moment()._lang._monthsShort.slice(), firstDay: 0, diff --git a/ckanext/datesearch/i18n/ckanext-datesearch.pot b/ckanext/datesearch/i18n/ckanext-datesearch.pot new file mode 100644 index 0000000..0a9b8d8 --- /dev/null +++ b/ckanext/datesearch/i18n/ckanext-datesearch.pot @@ -0,0 +1,73 @@ +# Translations template for ckanext-datesearch. +# Copyright (C) 2023 ORGANIZATION +# This file is distributed under the same license as the ckanext-datesearch +# project. +# FIRST AUTHOR , 2023. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: ckanext-datesearch 0.0\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2023-05-09 16:06+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.7.0\n" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:16 +msgid "Today" +msgstr "Heute" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:17 +msgid "Yesterday" +msgstr "Gestern" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:18 +msgid "Last 7 Days" +msgstr "Letzte 7 Tage" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:19 +msgid "Last 30 Days" +msgstr "Letzte 30 Tage" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:20 +msgid "This Month" +msgstr "In diesem Monat" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:21 +msgid "Last Month" +msgstr "Im letzten Monat" + +#: ckanext/datesearch/assets/js/daterangepicker.js:43 +msgid "Custom Range" +msgstr "Zeitraum festlegen" + +#: ckanext/datesearch/templates/package/search.html:8 +msgid "Filter by date" +msgstr "Zeitlicher Filter" + +#: ckanext/datesearch/templates/package/search.html:10 +msgid "Clear" +msgstr "Löschen" + +#: ckanext/spatial/templates/spatial/snippets/spatial_query.html:18 +msgid "Filter by location" +msgstr "Räumlicher filter" + +#: ckanext/spatial/public/js/spatial_query.js:92 +msgid "Please draw query extent in the map:" +msgstr "Bitte zeichnen Sie den Abfragebereich in die Karte ein:" + +#: ckanext/spatial/public/js/spatial_query.js:93 +msgid "Apply" +msgstr "Los" + +#: ckanext/spatial/templates/spatial/snippets/dataset_map.html:17 +#: ckanext/spatial/templates/spatial/snippets/dataset_map_sidebar.html:17 +msgid "Dataset extent" +msgstr "Räumliche Ausdehnung" + diff --git a/ckanext/datesearch/i18n/de/LC_MESSAGES/ckanext-datesearch.mo b/ckanext/datesearch/i18n/de/LC_MESSAGES/ckanext-datesearch.mo new file mode 100644 index 0000000000000000000000000000000000000000..d8df7b063138e8f0d77f8d4e40101017231fca84 GIT binary patch literal 1055 zcmZvaO>fgc5Qev+2pT?H3Ak_=B#=O8i@iXtvcxOF3Kc>b%2t4OuS7C2+aqRgC|0L|! zh$qH`I17IQ%)hxj;tg;L`tB&c37&xt!2-AgUI%wa`W=|>djL*=AHnyqFR&BPt9YFT z%V5554ZH;IfRo_fX#EYCpW^^L2Yv=Gg5SV-@H=<`92+0jn*>imUjap_*Gu|hJz-_U zdS+ePrMl8>7G>p>Wk>wlv36o3P8=I*^eIw~kI5u$Di^0(1j;&^^{A}+b|~hL`L$HL zj@UvS%M=;)ie6@H`lIbB*5o=&UDfkN*oiF-^TRY!eesMfYUkdTNndc&$!a8@vau-Z zQ*&2o98%`zviOZ=hrDU8Q0HE1oUGY)9Lcq;ZDpAHRH>D!!D^{ou2;6V3tNvvxo&uH zeu*DupNd{_R(f;NTcDZye(~OIujqM5ly%;V^Me1)o1Gixp%J^nCTlk65PI47X-zdaq2lyBDu^J(eII_c%?@kvoMUHH)}W81QZW1F*rOZa$(V1=!5(kThhO>1n&roYHZX#f}?>L{T5Uu(n=ZC7=rDPD-`Lrk} z)?$a`eMTwGnzmz18dz$y48Cr#$s_rwMTk692FV<2UsMMxmb;^U9&m;c-yBSx7QX?% Cq#8^B literal 0 HcmV?d00001 diff --git a/ckanext/datesearch/i18n/de/LC_MESSAGES/ckanext-datesearch.po b/ckanext/datesearch/i18n/de/LC_MESSAGES/ckanext-datesearch.po new file mode 100644 index 0000000..fd91b83 --- /dev/null +++ b/ckanext/datesearch/i18n/de/LC_MESSAGES/ckanext-datesearch.po @@ -0,0 +1,75 @@ +# German translations for ckanext-datesearch. +# Copyright (C) 2023 ORGANIZATION +# This file is distributed under the same license as the ckanext-datesearch +# project. +# FIRST AUTHOR , 2023. +# +msgid "" +msgstr "" +"Project-Id-Version: ckanext-datesearch 0.0\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2023-05-08 19:26+0200\n" +"PO-Revision-Date: 2023-05-08 19:35+0200\n" +"Last-Translator: FULL NAME \n" +"Language: de\n" +"Language-Team: de \n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.7.0\n" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:16 +msgid "Today" +msgstr "Heute" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:17 +msgid "Yesterday" +msgstr "Gestern" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:18 +msgid "Last 7 Days" +msgstr "Letzte 7 Tage" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:19 +msgid "Last 30 Days" +msgstr "Letzte 30 Tage" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:20 +msgid "This Month" +msgstr "In diesem Monat" + +#: ckanext/datesearch/assets/js/daterangepicker-module.js:21 +msgid "Last Month" +msgstr "Im letzten Monat" + +#: ckanext/datesearch/assets/js/daterangepicker.js:43 +msgid "Custom Range" +msgstr "Zeitraum festlegen" + +#: ckanext/datesearch/templates/package/search.html:8 +msgid "Filter by date" +msgstr "Zeitlicher Filter" + +#: ckanext/datesearch/templates/package/search.html:10 +msgid "Clear" +msgstr "Löschen" + +#: ckanext/spatial/templates/spatial/snippets/spatial_query.html:18 +msgid "Filter by location" +msgstr "Räumlicher filter" + +#: ckanext/spatial/public/js/spatial_query.js:92 +msgid "Please draw query extent in the map:" +msgstr "Bitte zeichnen Sie den Abfragebereich in die Karte ein:" + +#: ckanext/spatial/public/js/spatial_query.js:93 +msgid "Apply" +msgstr "Los" + +#: ckanext/spatial/templates/spatial/snippets/dataset_map.html:17 +#: ckanext/spatial/templates/spatial/snippets/dataset_map_sidebar.html:17 +msgid "Dataset extent" +msgstr "Räumliche Ausdehnung" + + diff --git a/ckanext/datesearch/plugin.py b/ckanext/datesearch/plugin.py index e7d02a7..9ed1174 100644 --- a/ckanext/datesearch/plugin.py +++ b/ckanext/datesearch/plugin.py @@ -1,8 +1,11 @@ import ckan.plugins as plugins import ckan.plugins.toolkit as toolkit +from ckan.lib.plugins import DefaultTranslation -class DateSearchPlugin(plugins.SingletonPlugin): + +class DateSearchPlugin(plugins.SingletonPlugin, DefaultTranslation): + plugins.implements(plugins.ITranslation) plugins.implements(plugins.IConfigurer) plugins.implements(plugins.IPackageController, inherit=True) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..a8a028e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,20 @@ +[extract_messages] +keywords = translate isPlural +add_comments = TRANSLATORS: +output_file = ckanext/datesearch/i18n/ckanext-datesearch.pot +width = 80 + +[init_catalog] +domain = ckanext-datesearch +input_file = ckanext/datesearch/i18n/ckanext-datesearch.pot +output_dir = ckanext/datesearch/i18n + +[update_catalog] +domain = ckanext-datesearch +input_file = ckanext/datesearch/i18n/ckanext-datesearch.pot +output_dir = ckanext/datesearch/i18n + +[compile_catalog] +domain = ckanext-datesearch +directory = ckanext/datesearch/i18n +statistics = true diff --git a/setup.py b/setup.py index e7b261b..47d352f 100644 --- a/setup.py +++ b/setup.py @@ -29,4 +29,11 @@ # myplugin=ckanext.datesearch:PluginClass datesearch=ckanext.datesearch.plugin:DateSearchPlugin """, + message_extractors={ + 'ckanext': [ + ('**.py', 'python', None), + ('**.js', 'javascript', None), + ('**/templates/**.html', 'ckan', None), + ], + } ) From 179595c7e2b741479c8f546dda12f196310417f2 Mon Sep 17 00:00:00 2001 From: Marija <93824048+MarijaKnezevic@users.noreply.github.com> Date: Thu, 11 May 2023 12:00:01 +0200 Subject: [PATCH 2/4] Update MANIFEST.in with i18n --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index b57d4dd..7a84baa 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ recursive-include ckanext/datesearch/templates * recursive-include ckanext/datesearch/assets *.html *.json *.js *.less *.css *.mo *.yml +recursive-include ckanext/datesearch/i18n From c6c35ed1e7658730fa82a98af67d57adff6c892b Mon Sep 17 00:00:00 2001 From: Marija <93824048+MarijaKnezevic@users.noreply.github.com> Date: Thu, 11 May 2023 12:32:39 +0200 Subject: [PATCH 3/4] Update MANIFEST.in update for i18n --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 7a84baa..c68c9f2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ recursive-include ckanext/datesearch/templates * recursive-include ckanext/datesearch/assets *.html *.json *.js *.less *.css *.mo *.yml -recursive-include ckanext/datesearch/i18n +recursive-include ckanext/datesearch/i18n *.po *.mo *.pot From 80bdfa872cf524ca175c46251892f42af843104e Mon Sep 17 00:00:00 2001 From: Marija <93824048+MarijaKnezevic@users.noreply.github.com> Date: Thu, 11 May 2023 16:12:14 +0200 Subject: [PATCH 4/4] Update MANIFEST.in i18n --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index c68c9f2..3ba62cc 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ recursive-include ckanext/datesearch/templates * recursive-include ckanext/datesearch/assets *.html *.json *.js *.less *.css *.mo *.yml -recursive-include ckanext/datesearch/i18n *.po *.mo *.pot +recursive-include ckanext/datesearch/i18n *