Skip to content

Commit

Permalink
Internationalization i18n, Polish translation #14
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofMadejski committed Mar 20, 2017
1 parent dd499d0 commit 06bbd10
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -2,3 +2,5 @@
*.egg-info
*.swp
*.swo

ckanext/report/i18n/_reused_translations.pot
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -247,3 +247,13 @@ def tagless_report_option_combinations():
yield {'organization': organization,
'include_sub_organizations': include_sub_organizations}
```

## Translations

To translate plugin to a new language (ie. "pl") run `python setup.py init_catalog -l pl`.

To update template file with new translation added in the code or templates
run `python setup.py extract_messages` in the root plugin directory. Then run
`./ckanext/report/i18n/unique_pot.sh -v` to strip core ckan's translations.

To update translation files for locale "pl" with new template run `python setup.py update_catalog -l pl`.
16 changes: 16 additions & 0 deletions babel.cfg
@@ -0,0 +1,16 @@
# Extraction from Python source files
[python: **.py]
# Extraction from Genshi HTML and text templates
[jinja2: **/templates/**.html]
encoding = utf-8
extensions =
jinja2.ext.do,
jinja2.ext.i18n,
jinja2.ext.with_,
ckan.lib.jinja_extensions.CkanExtend,
ckan.lib.jinja_extensions.CkanInternationalizationExtension,
ckan.lib.jinja_extensions.LinkForExtension,
ckan.lib.jinja_extensions.ResourceExtension,
ckan.lib.jinja_extensions.SnippetExtension,
ckan.lib.jinja_extensions.UrlForExtension,
ckan.lib.jinja_extensions.UrlForStaticExtension
103 changes: 103 additions & 0 deletions ckanext/report/i18n/ckanext-report.pot
@@ -0,0 +1,103 @@
# #-#-#-#-# ckanext-report.pot (ckanext-report 0.1) #-#-#-#-#
# Translations template for ckanext-report.
# Copyright (C) 2017 ORGANIZATION
# This file is distributed under the same license as the ckanext-report project.
#
msgid ""
msgstr ""
"#-#-#-#-# ckanext-report.pot (ckanext-report 0.1) #-#-#-#-#\n"
"Project-Id-Version: ckanext-report 0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2017-03-20 17:01+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"

#: ckanext/report/templates/report/index.html:3
#: ckanext/report/templates/report/index.html:6
#: ckanext/report/templates/report/view.html:3
#: ckanext/report/templates/report/view.html:6
msgid "Reports"
msgstr ""

#: ckanext/report/templates/report/index.html:26
msgid "View Report"
msgstr ""

#: ckanext/report/templates/report/option_include_sub_organizations.html:9
msgid "Include results from sub-organizations"
msgstr ""

#: ckanext/report/templates/report/option_organization.html:12
#: ckanext/report/templates/report/option_organization.html:16
msgid "Index of all organizations"
msgstr ""

#: ckanext/report/templates/report/tagless-datasets.html:8
msgid "Datasets without tags"
msgstr ""

#: ckanext/report/templates/report/tagless-datasets.html:9
msgid "Average tags per package"
msgstr ""

#: ckanext/report/templates/report/tagless-datasets.html:16
msgid "Notes"
msgstr ""

#: ckanext/report/templates/report/view.html:14
msgid "Generated"
msgstr ""

#: ckanext/report/templates/report/view.html:23
msgid ""
"As a system administrator you are able to refresh this report on demand by "
"clicking the 'Refresh' button."
msgstr ""

#: ckanext/report/templates/report/view.html:29
msgid "Options"
msgstr ""

#: ckanext/report/templates/report/view.html:50
msgid "Results"
msgstr ""

#: ckanext/report/templates/report/view.html:52
msgid "No results found."
msgstr ""

#: ckan/logic/converters.py:119 ckan/logic/validators.py:206
#: ckan/logic/validators.py:223 ckan/logic/validators.py:719
#: ckan/templates/group/members.html:17
#: ckan/templates/organization/members.html:17
#: ckanext/stats/templates/ckanext/stats/index.html:156
msgid "User"
msgstr ""

#: ckan/logic/converters.py:144 ckan/logic/validators.py:141
#: ckan/logic/validators.py:183 ckan/templates/package/read_base.html:24
#: ckanext/stats/templates/ckanext/stats/index.html:89
#: ckanext/stats/templates_legacy/ckanext/stats/index.html:65
#: ckanext/stats/templates_legacy/ckanext/stats/index.html:74
msgid "Dataset"
msgstr ""

#: ckan/templates/package/resource_read.html:43
#: ckan/templates/package/snippets/resource_item.html:45
msgid "Download"
msgstr ""

#: ckan/templates/package/resource_read.html:161
#: ckan/templates/package/snippets/additional_info.html:68
msgid "Created"
msgstr ""

#: ckan/templates/package/snippets/package_basic_fields.html:69
#: ckan/templates/snippets/organization.html:23
msgid "Organization"
msgstr ""
76 changes: 76 additions & 0 deletions ckanext/report/i18n/pl/LC_MESSAGES/ckanext-report.po
@@ -0,0 +1,76 @@
# Polish translations for ckanext-report.
# Copyright (C) 2017 ORGANIZATION
# This file is distributed under the same license as the ckanext-report
# project.
# Krzysztof Madejski <krzysztof.madejski@epf.org.pl>, 2017.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: krzysztof.madejski@epf.org.pl\n"
"POT-Creation-Date: 2017-03-20 17:02+0100\n"
"PO-Revision-Date: 2017-03-20 17:02+0100\n"
"Last-Translator: Krzysztof Madejski <krzysztof.madejski@epf.org.pl>\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && "
"(n%100<10 || n%100>=20) ? 1 : 2)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"

#: ckanext/report/templates/report/index.html:3
#: ckanext/report/templates/report/index.html:6
#: ckanext/report/templates/report/view.html:3
#: ckanext/report/templates/report/view.html:6
msgid "Reports"
msgstr "Raporty"

#: ckanext/report/templates/report/index.html:26
msgid "View Report"
msgstr "Zobacz Raport"

#: ckanext/report/templates/report/option_include_sub_organizations.html:9
msgid "Include results from sub-organizations"
msgstr "Dołącz wyniki od sub-organizacji"

#: ckanext/report/templates/report/option_organization.html:12
#: ckanext/report/templates/report/option_organization.html:16
msgid "Index of all organizations"
msgstr "Wszystkie organizacje"

#: ckanext/report/templates/report/tagless-datasets.html:8
msgid "Datasets without tags"
msgstr "Zbiory bez słów kluczowych"

#: ckanext/report/templates/report/tagless-datasets.html:9
msgid "Average tags per package"
msgstr "Średnia ilość słów kluczowych na zbiór"

#: ckanext/report/templates/report/tagless-datasets.html:16
msgid "Notes"
msgstr "Notatki"

#: ckanext/report/templates/report/view.html:14
msgid "Generated"
msgstr "Wygenerowany"

#: ckanext/report/templates/report/view.html:23
msgid ""
"As a system administrator you are able to refresh this report on demand "
"by clicking the 'Refresh' button."
msgstr ""
"Jako administrator możesz odświeżyć ten raport na żądanie "
"poprzez kliknięcie przycisku odśwież 'Refresh'."

#: ckanext/report/templates/report/view.html:29
msgid "Options"
msgstr "Opcje"

#: ckanext/report/templates/report/view.html:50
msgid "Results"
msgstr "Wyniki"

#: ckanext/report/templates/report/view.html:52
msgid "No results found."
msgstr "Nie znaleziono wyników"

64 changes: 64 additions & 0 deletions ckanext/report/i18n/unique_pot.sh
@@ -0,0 +1,64 @@
#!/bin/bash

# When you copy templates from CKAN (or other plugins) you end up with already translated translations in your pot file.
# This script filters them out from your .pot file. Run it right after `python setup.py extract_messages`

PLUGIN_NAME=report
PLUGIN_DEPENDENCIES=

SAVE_REUSED=0
VERBOSE=0
CURR_DIR=$(readlink -m $0/..)
SRC_DIR=$(readlink -m $0/../../../../..)

while getopts ":p:r:" opt; do
case $opt in
l) LANGUAGES="$OPTARG"
;;
p) PLUGIN_DEPENDENCIES="$OPTARG"
;;
r) SAVE_REUSED=1
;;
v) VERBOSE=1
;;
\?) echo "Invalid option -$OPTARG" >&2
;;
esac
done

function run_verbose {
if [ $VERBOSE ]; then
echo "# Running: $1"
fi
eval $1
}

# Find strings that we have reused from core CKAN and other plugins
DEP_POTS=""
for PLUGIN in $PLUGIN_DEPENDENCIES; do
DEP=$SRC_DIR/ckanext-$PLUGIN/ckanext/$PLUGIN/i18n/ckanext-$PLUGIN.pot
if [ -f $DEP ]; then
DEP_POTS="$DEP_POTS $DEP"
else
echo "Warning: .pot file for dependent $PLUGIN plugin doesn't exist, skipping $DEP"
fi
done

run_verbose "msgcat $SRC_DIR/ckan/ckan/i18n/ckan.pot $DEP_POTS -o $CURR_DIR/_dependencies.pot"

# Identify reused translations
touch $CURR_DIR/_reused_translations.pot
run_verbose "msgcat --use-first --more-than=1 $CURR_DIR/_dependencies.pot $CURR_DIR/ckanext-$PLUGIN_NAME.pot -o $CURR_DIR/_reused_translations.pot"

# Leave only unique strings in our pot
run_verbose "msgcat --unique $CURR_DIR/ckanext-$PLUGIN_NAME.pot $CURR_DIR/_reused_translations.pot -o $CURR_DIR/ckanext-$PLUGIN_NAME.pot"

rm $CURR_DIR/_dependencies.pot
if [ ! $SAVE_REUSED ]; then
rm $CURR_DIR/_reused_translations.pot
else
echo "Saving $CURR_DIR/_reused_translations.pot"
fi

echo ""
echo "I've updated $CURR_DIR/ckanext-$PLUGIN_NAME.pot."
Expand Up @@ -6,6 +6,6 @@
<span class="form-select control-group control-organization">
<label class="checkbox">
<input type="checkbox" name="include_sub_organizations" value="1" class="inline js-auto-submit" {{ 'checked=checked' if value }} />
Include results from sub-publishers
{% trans %}Include results from sub-organizations{% endtrans %}
</label>
</span>
6 changes: 3 additions & 3 deletions ckanext/report/templates/report/option_organization.html
Expand Up @@ -6,14 +6,14 @@
#}

<span class="form-select control-group control-organization">
<label for="option-organization"> {{ _('Publisher:') }} </label>
<label for="option-organization"> {{ _('Organization') }}: </label>
{% set offer_organization_index = (default == None) %}
{% if offer_organization_index and value != None %}
<a href="{{ h.report__relative_url_for(organization=None) }}">Index of all publishers</a>
<a href="{{ h.report__relative_url_for(organization=None) }}">{% trans %}Index of all organizations{% endtrans %}</a>
{% endif %}
<select id="option-organization" name="organization" class="inline js-auto-submit">
{% if offer_organization_index %}
<option value="" {% if value == None %}selected="selected"{% endif %}>-- {{ _('Index of all publishers') }} --</option>
<option value="" {% if value == None %}selected="selected"{% endif %}>-- {{ _('Index of all organizations') }} --</option>
{% endif %}
{% for org_name, org_title in h.report__organization_list() %}
<option value="{{org_name}}" {% if value == org_name %}selected="selected" {% endif %}> {{org_title}} </option>
Expand Down
12 changes: 6 additions & 6 deletions ckanext/report/templates/report/tagless-datasets.html
Expand Up @@ -5,17 +5,17 @@
data - other data values, as a dict
#}
<ul>
<li>Datasets without tags: {{ table|length }} / {{ data['num_packages'] }} ({{ data['packages_without_tags_percent'] }})</li>
<li>Average tags per package: {{ data['average_tags_per_package'] }} tags</li>
<li>{% trans %}Datasets without tags{% endtrans %}: {{ table|length }} / {{ data['num_packages'] }} ({{ data['packages_without_tags_percent'] }})</li>
<li>{% trans %}Average tags per package{% endtrans %}: {{ data['average_tags_per_package'] }} tags</li>
</ul>

<table class="table table-bordered table-condensed tablesorter" id="report-table" style="width: 100%; table-layout:fixed; margin-top: 8px;">
<thead>
<tr>
<th>Dataset</th>
<th>Notes</th>
<th>User</th>
<th>Created</th>
<th>{% trans %}Dataset{% endtrans %}</th>
<th>{% trans %}Notes{% endtrans %}</th>
<th>{% trans %}User{% endtrans %}</th>
<th>{% trans %}Created{% endtrans %}</th>
</tr>
</thead>
<tbody>
Expand Down
22 changes: 22 additions & 0 deletions setup.cfg
@@ -0,0 +1,22 @@
[extract_messages]
keywords = translate isPlural
add_comments = TRANSLATORS:
output_file = ckanext/report/i18n/ckanext-report.pot
width = 80
mapping_file = babel.cfg

[init_catalog]
domain = ckanext-report
input_file = ckanext/report/i18n/ckanext-report.pot
output_dir = ckanext/report/i18n

[update_catalog]
domain = ckanext-report
input_file = ckanext/report/i18n/ckanext-report.pot
output_dir = ckanext/report/i18n
previous = true

[compile_catalog]
domain = ckanext/report/ckanext-report
directory = i18n
statistics = true

0 comments on commit 06bbd10

Please sign in to comment.