Skip to content

Commit

Permalink
locales: Train settings
Browse files Browse the repository at this point in the history
  • Loading branch information
torzdf committed Jun 11, 2023
1 parent a66214c commit 02239d4
Show file tree
Hide file tree
Showing 5 changed files with 938 additions and 287 deletions.
25 changes: 16 additions & 9 deletions lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Extends out :class:`configparser.ConfigParser` functionality by checking for default
configuration updates and returning data in it's correct format """

import gettext
import logging
import os
import sys
Expand All @@ -16,6 +17,10 @@

from lib.utils import full_path_split

# LOCALES
_LANG = gettext.translation("lib.config", localedir="locales", fallback=True)
_ = _LANG.gettext

# Can't type OrderedDict fully on Python 3.8 or lower
if sys.version_info < (3, 9):
OrderedDictSectionType = OrderedDict
Expand Down Expand Up @@ -282,7 +287,9 @@ def _get_config_file(self, configfile: Optional[str]) -> str:
logger.error(err)
raise ValueError(err)
return configfile
dirname = os.path.dirname(sys.modules[self.__module__].__file__)
filepath = sys.modules[self.__module__].__file__
assert filepath is not None
dirname = os.path.dirname(filepath)
folder, fname = os.path.split(dirname)
retval = os.path.join(os.path.dirname(folder), "config", f"{fname}.ini")
logger.debug("Config File location: '%s'", retval)
Expand Down Expand Up @@ -383,23 +390,23 @@ def _expand_helptext(cls,
""" Add extra helptext info from parameters """
helptext += "\n"
if not fixed:
helptext += "\nThis option can be updated for existing models.\n"
helptext += _("\nThis option can be updated for existing models.\n")
if datatype == list:
helptext += ("\nIf selecting multiple options then each option should be separated "
"by a space or a comma (e.g. item1, item2, item3)\n")
helptext += _("\nIf selecting multiple options then each option should be separated "
"by a space or a comma (e.g. item1, item2, item3)\n")
if choices and choices != "colorchooser":
helptext += f"\nChoose from: {choices}"
helptext += _("\nChoose from: {}").format(choices)
elif datatype == bool:
helptext += "\nChoose from: True, False"
helptext += _("\nChoose from: True, False")
elif datatype == int:
assert min_max is not None
cmin, cmax = min_max
helptext += f"\nSelect an integer between {cmin} and {cmax}"
helptext += _("\nSelect an integer between {} and {}").format(cmin, cmax)
elif datatype == float:
assert min_max is not None
cmin, cmax = min_max
helptext += f"\nSelect a decimal number between {cmin} and {cmax}"
helptext += f"\n[Default: {default}]"
helptext += _("\nSelect a decimal number between {} and {}").format(cmin, cmax)
helptext += _("\n[Default: {}]").format(default)
return helptext

def _check_exists(self) -> bool:
Expand Down
61 changes: 61 additions & 0 deletions locales/lib.config.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-11 23:28+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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: lib/config.py:393
msgid ""
"\n"
"This option can be updated for existing models.\n"
msgstr ""

#: lib/config.py:395
msgid ""
"\n"
"If selecting multiple options then each option should be separated by a "
"space or a comma (e.g. item1, item2, item3)\n"
msgstr ""

#: lib/config.py:398
msgid ""
"\n"
"Choose from: {}"
msgstr ""

#: lib/config.py:400
msgid ""
"\n"
"Choose from: True, False"
msgstr ""

#: lib/config.py:404
msgid ""
"\n"
"Select an integer between {} and {}"
msgstr ""

#: lib/config.py:408
msgid ""
"\n"
"Select a decimal number between {} and {}"
msgstr ""

#: lib/config.py:409
msgid ""
"\n"
"[Default: {}]"
msgstr ""
Loading

0 comments on commit 02239d4

Please sign in to comment.