Browse Source

fix: fix English messages (#178)

Co-authored-by: Damgermys <damhub28@gmail.com>

Co-authored-by: Damgermys <damhub28@gmail.com>
tags/v0.10.0
Jérôme Deuchnord 3 years ago
committed by Jérôme Deuchnord
parent
commit
6661984973
5 changed files with 96 additions and 81 deletions
  1. +11
    -10
      _kosmorro/dumper.py
  2. +1
    -1
      _kosmorro/exceptions.py
  3. +1
    -1
      _kosmorro/i18n/strings.py
  4. +58
    -50
      _kosmorro/locales/messages.pot
  5. +25
    -19
      _kosmorro/main.py

+ 11
- 10
_kosmorro/dumper.py View File

@@ -24,6 +24,8 @@ import tempfile
import subprocess
import shutil
from pathlib import Path

from kosmorrolib.exceptions import UnavailableFeatureError
from tabulate import tabulate
from termcolor import colored

@@ -290,7 +292,7 @@ class _LatexDumper(Dumper):
) -> str:
document = document.replace("+++KOSMORRO-VERSION+++", version)
document = document.replace("+++KOSMORRO-LOGO+++", kosmorro_logo_path)
document = document.replace("+++DOCUMENT-TITLE+++", _("A Summary of your Sky"))
document = document.replace("+++DOCUMENT-TITLE+++", _("Overview of your sky"))
document = document.replace(
"+++DOCUMENT-DATE+++", self.get_date_as_string(capitalized=True)
)
@@ -474,14 +476,13 @@ class PdfDumper(Dumper):
)
return self._compile(latex_dumper.to_string())
except RuntimeError as error:
raise error
# raise UnavailableFeatureError(
# _(
# "Building PDFs was not possible, because some dependencies are not"
# " installed.\nPlease look at the documentation at http://kosmorro.space "
# "for more information."
# )
# ) from error
raise UnavailableFeatureError(
_(
"Building PDF was not possible, because some dependencies are not"
" installed.\nPlease look at the documentation at http://kosmorro.space "
"for more information."
)
) from error

@staticmethod
def is_file_output_needed() -> bool:
@@ -515,7 +516,7 @@ class PdfDumper(Dumper):

raise CompileError(
_(
"An error occured during the compilation of the PDF.\n"
"An error occurred during the compilation of the PDF.\n"
"Please open an issue at https://github.com/Kosmorro/kosmorro/issues and share "
"the content of the log file at /tmp/kosmorro-%s.log"
% timestamp


+ 1
- 1
_kosmorro/exceptions.py View File

@@ -32,7 +32,7 @@ class OutOfRangeDateError(RuntimeError):
self.min_date = min_date
self.max_date = max_date
self.msg = _(
"The date must be between {minimum_date}" " and {maximum_date}"
"The date must be between {minimum_date} and {maximum_date}"
).format(
minimum_date=min_date.strftime(SHORT_DATE_FORMAT),
maximum_date=max_date.strftime(SHORT_DATE_FORMAT),


+ 1
- 1
_kosmorro/i18n/strings.py View File

@@ -10,7 +10,7 @@ def from_event(event: Event) -> str:
EventType.OPPOSITION: _("%s is in opposition"),
EventType.CONJUNCTION: _("%s and %s are in conjunction"),
EventType.OCCULTATION: _("%s occults %s"),
EventType.MAXIMAL_ELONGATION: _("%s's largest elongation"),
EventType.MAXIMAL_ELONGATION: _("Elongation of %s is maximal"),
EventType.MOON_PERIGEE: _("%s is at its perigee"),
EventType.MOON_APOGEE: _("%s is at its apogee"),
}.get(event.event_type) % tuple([from_object(o.identifier) for o in event.objects])


+ 58
- 50
_kosmorro/locales/messages.pot View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: kosmorro 0.9.0\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-05-12 12:05+0200\n"
"POT-Creation-Date: 2021-05-15 16:28+0200\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"
@@ -27,79 +27,87 @@ msgid ""
"offset format."
msgstr ""

#: _kosmorro/dumper.py:106
#: _kosmorro/dumper.py:108
msgid "Expected events:"
msgstr ""

#: _kosmorro/dumper.py:113
#: _kosmorro/dumper.py:115
msgid "Note: All the hours are given in UTC."
msgstr ""

#: _kosmorro/dumper.py:120
#: _kosmorro/dumper.py:122
msgid "Note: All the hours are given in the UTC{offset} timezone."
msgstr ""

#: _kosmorro/dumper.py:184 _kosmorro/dumper.py:320
#: _kosmorro/dumper.py:186 _kosmorro/dumper.py:322
msgid "Object"
msgstr ""

#: _kosmorro/dumper.py:185 _kosmorro/dumper.py:321
#: _kosmorro/dumper.py:187 _kosmorro/dumper.py:323
msgid "Rise time"
msgstr ""

#: _kosmorro/dumper.py:186 _kosmorro/dumper.py:323
#: _kosmorro/dumper.py:188 _kosmorro/dumper.py:325
msgid "Culmination time"
msgstr ""

#: _kosmorro/dumper.py:187 _kosmorro/dumper.py:325
#: _kosmorro/dumper.py:189 _kosmorro/dumper.py:327
msgid "Set time"
msgstr ""

#: _kosmorro/dumper.py:221
#: _kosmorro/dumper.py:223
msgid "Moon phase is unavailable for this date."
msgstr ""

#: _kosmorro/dumper.py:225 _kosmorro/dumper.py:329
#: _kosmorro/dumper.py:227 _kosmorro/dumper.py:331
msgid "Moon phase:"
msgstr ""

#: _kosmorro/dumper.py:229
#: _kosmorro/dumper.py:231
msgid "{next_moon_phase} on {next_moon_phase_date} at {next_moon_phase_time}"
msgstr ""

#: _kosmorro/dumper.py:293
msgid "A Summary of your Sky"
#: _kosmorro/dumper.py:295
msgid "Overview of your sky"
msgstr ""

#: _kosmorro/dumper.py:301
#: _kosmorro/dumper.py:303
msgid ""
"This document summarizes the ephemerides and the events of {date}. It "
"aims to help you to prepare your observation session. All the hours are "
"given in {timezone}."
msgstr ""

#: _kosmorro/dumper.py:311
#: _kosmorro/dumper.py:313
msgid ""
"Don't forget to check the weather forecast before you go out with your "
"equipment."
msgstr ""

#: _kosmorro/dumper.py:318
#: _kosmorro/dumper.py:320
msgid "Ephemerides of the day"
msgstr ""

#: _kosmorro/dumper.py:327
#: _kosmorro/dumper.py:329
msgid "hours"
msgstr ""

#: _kosmorro/dumper.py:334
#: _kosmorro/dumper.py:336
msgid "Expected events"
msgstr ""

#: _kosmorro/dumper.py:517
#: _kosmorro/dumper.py:480
msgid ""
"Building PDF was not possible, because some dependencies are not "
"installed.\n"
"Please look at the documentation at http://kosmorro.space for more "
"information."
msgstr ""

#: _kosmorro/dumper.py:518
#, python-format
msgid ""
"An error occured during the compilation of the PDF.\n"
"An error occurred during the compilation of the PDF.\n"
"Please open an issue at https://github.com/Kosmorro/kosmorro/issues and "
"share the content of the log file at /tmp/kosmorro-%s.log"
msgstr ""
@@ -111,107 +119,107 @@ msgstr ""
#: _kosmorro/main.py:62
msgid ""
"Save the planet and paper!\n"
"Consider printing you PDF document only if really necessary, and use the "
"other side of the sheet."
"Consider printing your PDF document only if really necessary, and use the"
" other side of the sheet."
msgstr ""

#: _kosmorro/main.py:71
msgid ""
"PDF output will not contain the ephemerides, because you didn't provide "
"the observation coordinate."
"the observation coordinates."
msgstr ""

#: _kosmorro/main.py:116
msgid "Could not save the output in \"{path}\": {error}"
msgid "The file could not be saved in \"{path}\": {error}"
msgstr ""

#: _kosmorro/main.py:130
msgid "Selected output format needs an output file (--output)."
msgid "Please provide a file path to export in this format (--output)."
msgstr ""

#: _kosmorro/main.py:158
#: _kosmorro/main.py:163
msgid "Moon phase can only be displayed between {min_date} and {max_date}"
msgstr ""

#: _kosmorro/main.py:195
#: _kosmorro/main.py:202
msgid "Running on Python {python_version} with Kosmorrolib v{kosmorrolib_version}"
msgstr ""

#: _kosmorro/main.py:205
#: _kosmorro/main.py:212
msgid "Do you really want to clear Kosmorro's cache? [yN] "
msgstr ""

#: _kosmorro/main.py:213
msgid "Answer did not match expected options, cache not cleared."
#: _kosmorro/main.py:220
msgid "Incorrect answer, cache not cleared."
msgstr ""

#: _kosmorro/main.py:223
#: _kosmorro/main.py:230
msgid ""
"Compute the ephemerides and the events for a given date, at a given "
"Compute the ephemerides and the events for a given date and a given "
"position on Earth."
msgstr ""

#: _kosmorro/main.py:227
#: _kosmorro/main.py:233
msgid ""
"By default, only the events will be computed for today ({date}).\n"
"To compute also the ephemerides, latitude and longitude arguments are "
"needed."
msgstr ""

#: _kosmorro/main.py:241
#: _kosmorro/main.py:247
msgid "Show the program version"
msgstr ""

#: _kosmorro/main.py:249
msgid "Delete all the files Kosmorro stored in the cache."
#: _kosmorro/main.py:255
msgid "Delete all the files from Kosmorro's cache."
msgstr ""

#: _kosmorro/main.py:257
msgid "The format under which the information have to be output"
#: _kosmorro/main.py:263
msgid "The format to output the information to"
msgstr ""

#: _kosmorro/main.py:264
#: _kosmorro/main.py:270
msgid ""
"The observer's latitude on Earth. Can also be set in the "
"KOSMORRO_LATITUDE environment variable."
msgstr ""

#: _kosmorro/main.py:274
#: _kosmorro/main.py:280
msgid ""
"The observer's longitude on Earth. Can also be set in the "
"KOSMORRO_LONGITUDE environment variable."
msgstr ""

#: _kosmorro/main.py:284
#: _kosmorro/main.py:290
msgid ""
"The date for which the ephemerides must be computed (in the YYYY-MM-DD "
"format), or as an interval in the \"[+-]YyMmDd\" format (with Y, M, and D"
" numbers). Defaults to the current date ({default_date})"
"The date for which the ephemerides must be calculated. Can be in the "
"YYYY-MM-DD format or an interval in the \"[+-]YyMmDd\" format (with Y, M,"
" and D numbers). Defaults to today ({default_date})."
msgstr ""

#: _kosmorro/main.py:295
#: _kosmorro/main.py:301
msgid ""
"The timezone to display the hours in (e.g. 2 for UTC+2 or -3 for UTC-3). "
"Can also be set in the KOSMORRO_TIMEZONE environment variable."
msgstr ""

#: _kosmorro/main.py:304
#: _kosmorro/main.py:310
msgid "Disable the colors in the console."
msgstr ""

#: _kosmorro/main.py:311
#: _kosmorro/main.py:317
msgid ""
"A file to export the output to. If not given, the standard output is "
"used. This argument is needed for PDF format."
msgstr ""

#: _kosmorro/main.py:320
#: _kosmorro/main.py:326
msgid ""
"Do not generate a graph to represent the rise and set times in the PDF "
"format."
msgstr ""

#: _kosmorro/main.py:328
#: _kosmorro/main.py:334
msgid "Show debugging messages"
msgstr ""

@@ -232,7 +240,7 @@ msgstr ""

#: _kosmorro/i18n/strings.py:13
#, python-format
msgid "%s's largest elongation"
msgid "Elongation of %s is maximal"
msgstr ""

#: _kosmorro/i18n/strings.py:14


+ 25
- 19
_kosmorro/main.py View File

@@ -30,8 +30,8 @@ from termcolor import colored
from . import dumper, environment, debug
from .date import parse_date
from .__version__ import __version__ as kosmorro_version
from .exceptions import UnavailableFeatureError
from _kosmorro.i18n.utils import _
from .exceptions import UnavailableFeatureError, OutOfRangeDateError as DateRangeError
from _kosmorro.i18n.utils import _, SHORT_DATE_FORMAT


def main():
@@ -61,7 +61,7 @@ def main():
print(
_(
"Save the planet and paper!\n"
"Consider printing you PDF document only if really necessary, and use the other side of the sheet."
"Consider printing your PDF document only if really necessary, and use the other side of the sheet."
)
)
if position is None:
@@ -70,7 +70,7 @@ def main():
colored(
_(
"PDF output will not contain the ephemerides, because you didn't provide the observation "
"coordinate."
"coordinates."
),
"yellow",
)
@@ -96,7 +96,7 @@ def main():
print(colored(error.msg, "red"))
debug.debug_print(error)
return 2
except OutOfRangeDateError as error:
except DateRangeError as error:
print(colored(error.msg, "red"))
debug.debug_print(error)
return 1
@@ -113,7 +113,7 @@ def main():
except OSError as error:
print(
colored(
_('Could not save the output in "{path}": {error}').format(
_('The file could not be saved in "{path}": {error}').format(
path=args.output, error=error.strerror
),
"red",
@@ -127,7 +127,7 @@ def main():
else:
print(
colored(
_("Selected output format needs an output file (--output)."),
_("Please provide a file path to export in this format (--output)."),
color="red",
)
)
@@ -145,7 +145,12 @@ def get_information(
show_graph: bool,
) -> dumper.Dumper:
if position is not None:
eph = get_ephemerides(date=compute_date, position=position, timezone=timezone)
try:
eph = get_ephemerides(
date=compute_date, position=position, timezone=timezone
)
except OutOfRangeDateError as error:
raise DateRangeError(error.min_date, error.max_date)
else:
eph = None

@@ -156,9 +161,11 @@ def get_information(
print(
colored(
_(
"Moon phase can only be displayed"
" between {min_date} and {max_date}"
).format(min_date=error.min_date, max_date=error.max_date),
"Moon phase can only be displayed between {min_date} and {max_date}"
).format(
min_date=error.min_date.strftime(SHORT_DATE_FORMAT),
max_date=error.max_date.strftime(SHORT_DATE_FORMAT),
),
"yellow",
)
)
@@ -210,7 +217,7 @@ def clear_cache() -> bool:
debug.debug_print("No cache found, nothing done.")
pass
elif confirm != "" and re.match(locale.nl_langinfo(locale.NOEXPR), confirm) is None:
print(_("Answer did not match expected options, cache not cleared."))
print(_("Incorrect answer, cache not cleared."))
return False

return True
@@ -221,8 +228,7 @@ def get_args(output_formats: [str]):

parser = argparse.ArgumentParser(
description=_(
"Compute the ephemerides and the events for a given date,"
" at a given position on Earth."
"Compute the ephemerides and the events for a given date and a given position on Earth."
),
epilog=_(
"By default, only the events will be computed for today ({date}).\n"
@@ -246,7 +252,7 @@ def get_args(output_formats: [str]):
action="store_const",
const=clear_cache,
default=None,
help=_("Delete all the files Kosmorro stored in the cache."),
help=_("Delete all the files from Kosmorro's cache."),
)
parser.add_argument(
"--format",
@@ -254,7 +260,7 @@ def get_args(output_formats: [str]):
type=str,
default=output_formats[0],
choices=output_formats,
help=_("The format under which the information have to be output"),
help=_("The format to output the information to"),
)
parser.add_argument(
"--latitude",
@@ -282,9 +288,9 @@ def get_args(output_formats: [str]):
type=str,
default=today.strftime("%Y-%m-%d"),
help=_(
"The date for which the ephemerides must be computed (in the YYYY-MM-DD format), "
'or as an interval in the "[+-]YyMmDd" format (with Y, M, and D numbers). '
"Defaults to the current date ({default_date})"
"The date for which the ephemerides must be calculated. Can be in the YYYY-MM-DD format "
'or an interval in the "[+-]YyMmDd" format (with Y, M, and D numbers). '
"Defaults to today ({default_date})."
).format(default_date=today.strftime("%Y-%m-%d")),
)
parser.add_argument(


Loading…
Cancel
Save