Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18n #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name = "pypi"

[packages]
"e1839a8" = {path = ".", editable = true}
cjwmodule = ">=1.3.0"

[dev-packages]

Expand Down
356 changes: 221 additions & 135 deletions Pipfile.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions libraryofcongress.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from urllib.parse import urlencode
import aiohttp
import pandas as pd
from cjwmodule import i18n


BaseUrl = 'https://www.loc.gov/search/'
Expand Down Expand Up @@ -80,7 +81,7 @@ async def fetch(params):
q = params['q']

if not q:
return (None, 'Missing search phrase')
return (None, i18n.trans("badParam.q.missing", 'Missing search phrase'))

facets = []
if params['partof'] != 'entire_library':
Expand All @@ -96,9 +97,10 @@ async def fetch(params):
try:
return await _fetch_paginated(q, fa)
except aiohttp.client_exceptions.ClientResponseError as err:
return (
'HTTP error from Library of Congress server: %(code)d %(message)s'
% {'code': err.code, 'message': err.message}
return i18n.trans(
"error.http.general",
'HTTP error from Library of Congress server: {code} {message}',
{'code': err.code, 'message': err.message}
)


Expand Down
68 changes: 68 additions & 0 deletions locale/el/messages.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Greek translations for PROJECT.
# Copyright (C) 2020 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2020.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2020-02-18 15:45+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: el\n"
"Language-Team: el <[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.8.0\n"

msgid "_spec.name"
msgstr "Βιβλιοθήκη του Κογκρέσου"

msgid "_spec.description"
msgstr "Αναζήτηση στη Βιβλιοθήκη του Κογκρέσου για αρχεία εγγράφων"

msgid "_spec.parameters.q.name"
msgstr "Λέξεις-κλειδιά"

msgid "_spec.parameters.q.placeholder"
msgstr "Λέξεις-κλειδιά"

msgid "_spec.parameters.partof.name"
msgstr "Συλλογή"

msgid "_spec.parameters.partof.options.entire_library.label"
msgstr "Ολόκληρη η βιβλιοθήκη"

msgid "_spec.parameters.partof.options.bills.label"
msgstr "Νομοσχέδια"

msgid "_spec.parameters.partof.options.house_bills.label"
msgstr "Νομοσχέδια της Βουλής Αντιπροσώπων"

msgid "_spec.parameters.partof.options.senate_bills.label"
msgstr "Νομοσχέδια της Γερουσίας"

msgid "_spec.parameters.partof.options.house_resolutions.label"
msgstr "Ψηφίσματα της Βουλής Αντιπροσώπων"

msgid "_spec.parameters.partof.options.senate_resolutions.label"
msgstr "Ψηφίσματα της Γερουσίας"

msgid "_spec.parameters.partof.options.federal_register.label"
msgstr "Ομοσπονδιακό Μητρώο"

msgid "_spec.parameters.version_select.name"
msgstr "Αναζήτηση"

#: libraryofcongress.py:84
msgid "badParam.q.missing"
msgstr "Δεν υπάρχει φράση αναζήτησης"

#: libraryofcongress.py:100
msgid "error.http.general"
msgstr "Σφάλμα HTTP από τον διακομιστή της Βιβλιοθήκης του Κογκρέσου: {code} {message}"

68 changes: 68 additions & 0 deletions locale/en/messages.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# English translations for PROJECT.
# Copyright (C) 2020 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2020.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2020-02-07 17:20+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
"Language-Team: en <[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.8.0\n"

msgid "_spec.name"
msgstr "Library of Congress"

msgid "_spec.description"
msgstr "Search the Library of Congress for records of documents"

msgid "_spec.parameters.q.name"
msgstr "Keywords"

msgid "_spec.parameters.q.placeholder"
msgstr "Keywords"

msgid "_spec.parameters.partof.name"
msgstr "Collection"

msgid "_spec.parameters.partof.options.entire_library.label"
msgstr "Entire library"

msgid "_spec.parameters.partof.options.bills.label"
msgstr "Bills"

msgid "_spec.parameters.partof.options.house_bills.label"
msgstr "House bills"

msgid "_spec.parameters.partof.options.senate_bills.label"
msgstr "Senate bills"

msgid "_spec.parameters.partof.options.house_resolutions.label"
msgstr "House resolutions"

msgid "_spec.parameters.partof.options.senate_resolutions.label"
msgstr "Senate resolutions"

msgid "_spec.parameters.partof.options.federal_register.label"
msgstr "Federal register"

msgid "_spec.parameters.version_select.name"
msgstr "Search"

#: libraryofcongress.py:84
msgid "badParam.q.missing"
msgstr "Missing search phrase"

#: libraryofcongress.py:100
msgid "error.http.general"
msgstr "HTTP error from Library of Congress server: {code} {message}"

62 changes: 62 additions & 0 deletions locale/templates/messages.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#. default-message: Library of Congress
msgid "_spec.name"
msgstr ""

#. default-message: Search the Library of Congress for records of documents
msgid "_spec.description"
msgstr ""

#. default-message: Keywords
msgid "_spec.parameters.q.name"
msgstr ""

#. default-message: Keywords
msgid "_spec.parameters.q.placeholder"
msgstr ""

#. default-message: Collection
msgid "_spec.parameters.partof.name"
msgstr ""

#. default-message: Entire library
msgid "_spec.parameters.partof.options.entire_library.label"
msgstr ""

#. default-message: Bills
msgid "_spec.parameters.partof.options.bills.label"
msgstr ""

#. default-message: House bills
msgid "_spec.parameters.partof.options.house_bills.label"
msgstr ""

#. default-message: Senate bills
msgid "_spec.parameters.partof.options.senate_bills.label"
msgstr ""

#. default-message: House resolutions
msgid "_spec.parameters.partof.options.house_resolutions.label"
msgstr ""

#. default-message: Senate resolutions
msgid "_spec.parameters.partof.options.senate_resolutions.label"
msgstr ""

#. default-message: Federal register
msgid "_spec.parameters.partof.options.federal_register.label"
msgstr ""

#. default-message: Search
msgid "_spec.parameters.version_select.name"
msgstr ""

#. default-message: Missing search phrase
#: libraryofcongress.py:84
msgid "badParam.q.missing"
msgstr ""

#. default-message: HTTP error from Library of Congress server: {code} {message}
#: libraryofcongress.py:100
msgid "error.http.general"
msgstr ""

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
url='https://github.com/CJWorkbench/libraryofcongress',
packages=[''],
py_modules=['libraryofcongress'],
install_requires=['pandas==0.24.2', 'aiohttp']
install_requires=['pandas==0.24.2', 'aiohttp', "cjwmodule>=1.3.0"]
)