Skip to content

Commit

Permalink
Merge pull request #3 from MarijaKnezevic/internationalization
Browse files Browse the repository at this point in the history
fix for daterangepicker and add internationalization
  • Loading branch information
BWibo authored May 22, 2023
2 parents d5af9d4 + 80bdfa8 commit 3b6f9b4
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 8 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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 *
21 changes: 15 additions & 6 deletions ckanext/datesearch/assets/js/daterangepicker-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ this.ckan.module('daterangepicker-module', function($, _) {
$('<input type="hidden" id="ext_enddate" name="ext_enddate" />').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 <input> 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(),
Expand Down
2 changes: 1 addition & 1 deletion ckanext/datesearch/assets/js/daterangepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
73 changes: 73 additions & 0 deletions ckanext/datesearch/i18n/ckanext-datesearch.pot
Original file line number Diff line number Diff line change
@@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\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"

Binary file not shown.
75 changes: 75 additions & 0 deletions ckanext/datesearch/i18n/de/LC_MESSAGES/ckanext-datesearch.po
Original file line number Diff line number Diff line change
@@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language: de\n"
"Language-Team: de <[email protected]>\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"


5 changes: 4 additions & 1 deletion ckanext/datesearch/plugin.py
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
20 changes: 20 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
}
)

0 comments on commit 3b6f9b4

Please sign in to comment.