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

German translation #308

Merged
merged 7 commits into from
May 20, 2024
Merged
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
3 changes: 1 addition & 2 deletions ui/book/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class UserState:
def __init__(self, root: 'state.RootState'):
self.root = root
self.current_book = manual_filename
# should default be en_GB:en ??
self.current_language = DEFAULT_LOCALE.code
self.current_language = DEFAULT_LOCALE
self.books = OrderedDict({manual_filename: manual})

@property
Expand Down
36 changes: 17 additions & 19 deletions ui/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,31 @@ def _(x): return x
# might be irrelevant if there are no British-isms in this small
# collection of text, (3) US users might object on principle.

# TRANSLATORS: This is a language name menu item, so should always appear
# in the language it denotes so that it remains readable to those who
# speak only that language, just as "Deutsch" should always be left as
# "Deutsch" in a language menu. Addition of a Braille grade marker seems
# appropriate, if possible.
ueb1 = Builtin(code='en_GB.UTF-8@ueb1', title=_('English, UEB grade 1'))

# TRANSLATORS: This is a language name menu item, so should always appear
# in the language it denotes so that it remains readable to those who
# speak only that language, just as "Deutsch" should always be left as
# "Deutsch" in a language menu. Addition of a Braille grade marker seems
# appropriate, if possible.
ueb2 = Builtin(code='en_GB.UTF-8@ueb2', title=_('English, UEB grade 2'))
builtin = [
# TRANSLATORS: This is a language name menu item, so should always appear
# in the language it denotes so that it remains readable to those who
# speak only that language, just as "Deutsch" should always be left as
# "Deutsch" in a language menu. Addition of a Braille grade marker seems
# appropriate, if possible.
Builtin(code='en_GB.UTF-8@ueb1', title=_('English, UEB grade 1')),
# TRANSLATORS: This is a language name menu item.
Builtin(code='en_GB.UTF-8@ueb2', title=_('English, UEB grade 2')),
# TRANSLATORS: This is a language name menu item.
Builtin(code='de_DE.UTF-8@ueb1', title=_('Deutsch, UEB grade 1')),
# TRANSLATORS: This is a language name menu item.
Builtin(code='de_DE.UTF-8@ueb2', title=_('Deutsch, UEB grade 2'))
]

del _

DEFAULT_LOCALE = ueb2
DEFAULT_LOCALE = 'en_GB.UTF-8@ueb2'

translations = install(DEFAULT_LOCALE.code)
translations = install(DEFAULT_LOCALE)
# this will've already been installed globally, but this keeps flake8 happy
_ = translations.gettext

# Rely on dedup.
BUILTIN_LANGUAGES = OrderedDict([
(DEFAULT_LOCALE.code, _(DEFAULT_LOCALE.title)),
(ueb1.code, _(ueb1.title)),
(ueb2.code, _(ueb2.title)),
(lang.code, _(lang.title)) for lang in builtin
])

# For detecting the default language of older installations, which
Expand Down
4 changes: 2 additions & 2 deletions ui/initial_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .cleaning_and_testing import CleaningAndTesting, cleaning_filename
from .book.book_file import BookFile
from .library.explorer import Library, Directory, LocalFile
from .i18n import install, DEFAULT_LOCALE, BUILTIN_LANGUAGES, OLD_DEFAULT_LOCALE
from .i18n import install, DEFAULT_LOCALE, OLD_DEFAULT_LOCALE

from . import config_loader

Expand Down Expand Up @@ -111,7 +111,7 @@ async def read_user_state(media_dir, state):
log.warning(f'user state loading failed for {main_toml}, ignoring')

if not current_language or current_language == OLD_DEFAULT_LOCALE:
current_language = DEFAULT_LOCALE.code
current_language = DEFAULT_LOCALE

install(current_language)
manual = Manual.create()
Expand Down
7 changes: 7 additions & 0 deletions ui/locale/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ corresponding MO, e.g.:
pybabel compile -f -D canute -d . -l en_GB.UTF-8@ueb1 -i en_GB.UTF-8@ueb1/LC_MESSAGES/canute.po

To see tweaks applied in the past, check the git diff.
___

If you get the error `ModuleNotFoundError: No module named 'louis'` you may
need to run something like the following first:

export PYTHONPATH="$(brew --prefix liblouis)/lib/python3.12/site-packages:$PYTHONPATH"

8 changes: 8 additions & 0 deletions ui/locale/autotranslate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
'en-ueb-g1.ctb', 'en_GB.UTF-8@ueb1'),
Variant('British English, UEB grade 2',
'en-ueb-g2.ctb', 'en_GB.UTF-8@ueb2'),
Variant('Deutsch, UEB grade 2',
'de-g1-detailed.ctb', 'de_DE.UTF-8@ueb1'),
Variant('Deutsch, UEB grade 2',
'de-g2.ctb', 'de_DE.UTF-8@ueb2'),
]

for variant in variants:
Expand Down Expand Up @@ -86,6 +90,10 @@
dest_entry.msgstr = '⠠⠑⠝⠛⠇⠊⠎⠓⠂ ⠠⠠⠥⠑⠃ ⠛⠗⠁⠙⠑ ⠼⠁'
elif dest_entry.msgid == 'English, UEB grade 2':
dest_entry.msgstr = '⠠⠢⠛⠇⠊⠩⠂ ⠠⠠⠥⠑⠃ ⠛⠗⠁⠙⠑ ⠼⠃'
elif dest_entry.msgid == 'Deutsch, UEB grade 1':
dest_entry.msgstr = '⠙⠣⠞⠱⠂⠀⠥⠑⠃⠀⠛⠗⠁⠙⠑⠀⠼⠁'
elif dest_entry.msgid == 'Deutsch, UEB grade 2':
dest_entry.msgstr = '⠙⠱⠂⠀⠥⠑⠃⠀⠛⠗⠁⠙⠑⠀⠼⠃'
dest.append(dest_entry)

destdir = os.path.join(variant.locale, 'LC_MESSAGES')
Expand Down
30 changes: 18 additions & 12 deletions ui/locale/canute.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-04-26 15:25+0100\n"
"POT-Creation-Date: 2024-05-20 13:12+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -22,19 +22,25 @@ msgstr ""
#. speak only that language, just as "Deutsch" should always be left as
#. "Deutsch" in a language menu. Addition of a Braille grade marker seems
#. appropriate, if possible.
#: ui/i18n.py:38
#: ui/i18n.py:39
msgid "English, UEB grade 1"
msgstr ""

#. TRANSLATORS: This is a language name menu item, so should always appear
#. in the language it denotes so that it remains readable to those who
#. speak only that language, just as "Deutsch" should always be left as
#. "Deutsch" in a language menu. Addition of a Braille grade marker seems
#. appropriate, if possible.
#: ui/i18n.py:45
#. TRANSLATORS: This is a language name menu item.
#: ui/i18n.py:41
msgid "English, UEB grade 2"
msgstr ""

#. TRANSLATORS: This is a language name menu item.
#: ui/i18n.py:43
msgid "Deutsch, UEB grade 1"
msgstr ""

#. TRANSLATORS: This is a language name menu item.
#: ui/i18n.py:45
msgid "Deutsch, UEB grade 2"
msgstr ""

#: ui/manual.py:34
msgid ""
"Canute 360 by Bristol Braille Technology\n"
Expand Down Expand Up @@ -107,7 +113,7 @@ msgstr ""
msgid "view library menu"
msgstr ""

#: ui/bookmarks/help.py:7
#: ui/bookmarks_menu/help.py:7
msgid ""
"To navigate to a bookmark within a file press the line select button "
"immediately to the left of your chosen bookmark. From the bookmark menu "
Expand All @@ -120,15 +126,15 @@ msgid ""
msgstr ""

#. TRANSLATORS: Bookmarks menu title; gets followed by book name
#: ui/bookmarks/view.py:27
#: ui/bookmarks_menu/view.py:27
msgid "bookmarks:"
msgstr ""

#: ui/bookmarks/view.py:35
#: ui/bookmarks_menu/view.py:35
msgid "start of book"
msgstr ""

#: ui/bookmarks/view.py:37
#: ui/bookmarks_menu/view.py:37
msgid "end of book"
msgstr ""

Expand Down
Binary file added ui/locale/de_DE.UTF-8@ueb1/LC_MESSAGES/canute.mo
Binary file not shown.
Loading