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 subprocess
import shutil import shutil
from pathlib import Path from pathlib import Path

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


@@ -290,7 +292,7 @@ class _LatexDumper(Dumper):
) -> str: ) -> str:
document = document.replace("+++KOSMORRO-VERSION+++", version) document = document.replace("+++KOSMORRO-VERSION+++", version)
document = document.replace("+++KOSMORRO-LOGO+++", kosmorro_logo_path) 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 = document.replace(
"+++DOCUMENT-DATE+++", self.get_date_as_string(capitalized=True) "+++DOCUMENT-DATE+++", self.get_date_as_string(capitalized=True)
) )
@@ -474,14 +476,13 @@ class PdfDumper(Dumper):
) )
return self._compile(latex_dumper.to_string()) return self._compile(latex_dumper.to_string())
except RuntimeError as error: 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 @staticmethod
def is_file_output_needed() -> bool: def is_file_output_needed() -> bool:
@@ -515,7 +516,7 @@ class PdfDumper(Dumper):


raise CompileError( 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 " "Please open an issue at https://github.com/Kosmorro/kosmorro/issues and share "
"the content of the log file at /tmp/kosmorro-%s.log" "the content of the log file at /tmp/kosmorro-%s.log"
% timestamp % timestamp


+ 1
- 1
_kosmorro/exceptions.py View File

@@ -32,7 +32,7 @@ class OutOfRangeDateError(RuntimeError):
self.min_date = min_date self.min_date = min_date
self.max_date = max_date self.max_date = max_date
self.msg = _( self.msg = _(
"The date must be between {minimum_date}" " and {maximum_date}"
"The date must be between {minimum_date} and {maximum_date}"
).format( ).format(
minimum_date=min_date.strftime(SHORT_DATE_FORMAT), minimum_date=min_date.strftime(SHORT_DATE_FORMAT),
maximum_date=max_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.OPPOSITION: _("%s is in opposition"),
EventType.CONJUNCTION: _("%s and %s are in conjunction"), EventType.CONJUNCTION: _("%s and %s are in conjunction"),
EventType.OCCULTATION: _("%s occults %s"), 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_PERIGEE: _("%s is at its perigee"),
EventType.MOON_APOGEE: _("%s is at its apogee"), EventType.MOON_APOGEE: _("%s is at its apogee"),
}.get(event.event_type) % tuple([from_object(o.identifier) for o in event.objects]) }.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 "" msgstr ""
"Project-Id-Version: kosmorro 0.9.0\n" "Project-Id-Version: kosmorro 0.9.0\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -27,79 +27,87 @@ msgid ""
"offset format." "offset format."
msgstr "" msgstr ""


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


#: _kosmorro/dumper.py:334
#: _kosmorro/dumper.py:336
msgid "Expected events" msgid "Expected events"
msgstr "" 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 #, python-format
msgid "" 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 " "Please open an issue at https://github.com/Kosmorro/kosmorro/issues and "
"share the content of the log file at /tmp/kosmorro-%s.log" "share the content of the log file at /tmp/kosmorro-%s.log"
msgstr "" msgstr ""
@@ -111,107 +119,107 @@ msgstr ""
#: _kosmorro/main.py:62 #: _kosmorro/main.py:62
msgid "" msgid ""
"Save the planet and paper!\n" "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 "" msgstr ""


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


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


#: _kosmorro/main.py:130 #: _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 "" msgstr ""


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


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


#: _kosmorro/main.py:205
#: _kosmorro/main.py:212
msgid "Do you really want to clear Kosmorro's cache? [yN] " msgid "Do you really want to clear Kosmorro's cache? [yN] "
msgstr "" 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 "" msgstr ""


#: _kosmorro/main.py:223
#: _kosmorro/main.py:230
msgid "" 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." "position on Earth."
msgstr "" msgstr ""


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


#: _kosmorro/main.py:241
#: _kosmorro/main.py:247
msgid "Show the program version" msgid "Show the program version"
msgstr "" 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 "" 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 "" msgstr ""


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


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


#: _kosmorro/main.py:284
#: _kosmorro/main.py:290
msgid "" 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 "" msgstr ""


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


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


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


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


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


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


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


#: _kosmorro/i18n/strings.py:14 #: _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 . import dumper, environment, debug
from .date import parse_date from .date import parse_date
from .__version__ import __version__ as kosmorro_version 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(): def main():
@@ -61,7 +61,7 @@ def main():
print( print(
_( _(
"Save the planet and paper!\n" "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: if position is None:
@@ -70,7 +70,7 @@ def main():
colored( colored(
_( _(
"PDF output will not contain the ephemerides, because you didn't provide the observation " "PDF output will not contain the ephemerides, because you didn't provide the observation "
"coordinate."
"coordinates."
), ),
"yellow", "yellow",
) )
@@ -96,7 +96,7 @@ def main():
print(colored(error.msg, "red")) print(colored(error.msg, "red"))
debug.debug_print(error) debug.debug_print(error)
return 2 return 2
except OutOfRangeDateError as error:
except DateRangeError as error:
print(colored(error.msg, "red")) print(colored(error.msg, "red"))
debug.debug_print(error) debug.debug_print(error)
return 1 return 1
@@ -113,7 +113,7 @@ def main():
except OSError as error: except OSError as error:
print( print(
colored( 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 path=args.output, error=error.strerror
), ),
"red", "red",
@@ -127,7 +127,7 @@ def main():
else: else:
print( print(
colored( colored(
_("Selected output format needs an output file (--output)."),
_("Please provide a file path to export in this format (--output)."),
color="red", color="red",
) )
) )
@@ -145,7 +145,12 @@ def get_information(
show_graph: bool, show_graph: bool,
) -> dumper.Dumper: ) -> dumper.Dumper:
if position is not None: 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: else:
eph = None eph = None


@@ -156,9 +161,11 @@ def get_information(
print( print(
colored( 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", "yellow",
) )
) )
@@ -210,7 +217,7 @@ def clear_cache() -> bool:
debug.debug_print("No cache found, nothing done.") debug.debug_print("No cache found, nothing done.")
pass pass
elif confirm != "" and re.match(locale.nl_langinfo(locale.NOEXPR), confirm) is None: 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 False


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


parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description=_( 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=_( epilog=_(
"By default, only the events will be computed for today ({date}).\n" "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", action="store_const",
const=clear_cache, const=clear_cache,
default=None, default=None,
help=_("Delete all the files Kosmorro stored in the cache."),
help=_("Delete all the files from Kosmorro's cache."),
) )
parser.add_argument( parser.add_argument(
"--format", "--format",
@@ -254,7 +260,7 @@ def get_args(output_formats: [str]):
type=str, type=str,
default=output_formats[0], default=output_formats[0],
choices=output_formats, 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( parser.add_argument(
"--latitude", "--latitude",
@@ -282,9 +288,9 @@ def get_args(output_formats: [str]):
type=str, type=str,
default=today.strftime("%Y-%m-%d"), default=today.strftime("%Y-%m-%d"),
help=_( 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")), ).format(default_date=today.strftime("%Y-%m-%d")),
) )
parser.add_argument( parser.add_argument(


Loading…
Cancel
Save