diff --git a/locale/widgets/de.png b/locale/widgets/de.png index 884d420..204c79c 100644 Binary files a/locale/widgets/de.png and b/locale/widgets/de.png differ diff --git a/locale/widgets/es.png b/locale/widgets/es.png index c9de77e..d766667 100644 Binary files a/locale/widgets/es.png and b/locale/widgets/es.png differ diff --git a/locale/widgets/fr.png b/locale/widgets/fr.png index 659445f..7257659 100644 Binary files a/locale/widgets/fr.png and b/locale/widgets/fr.png differ diff --git a/locale/widgets/hi.png b/locale/widgets/hi.png index 6257e3a..b5ba72a 100644 Binary files a/locale/widgets/hi.png and b/locale/widgets/hi.png differ diff --git a/locale/widgets/it.png b/locale/widgets/it.png index 1cb63fc..61cb768 100644 Binary files a/locale/widgets/it.png and b/locale/widgets/it.png differ diff --git a/locale/widgets/pl.png b/locale/widgets/pl.png index 03fc56a..9a50f04 100644 Binary files a/locale/widgets/pl.png and b/locale/widgets/pl.png differ diff --git a/locale/widgets/pt-br.png b/locale/widgets/pt-br.png index 535b9c3..4ba5ca5 100644 Binary files a/locale/widgets/pt-br.png and b/locale/widgets/pt-br.png differ diff --git a/locale/widgets/ru.png b/locale/widgets/ru.png index fe94915..b5ba72a 100644 Binary files a/locale/widgets/ru.png and b/locale/widgets/ru.png differ diff --git a/locale/widgets/uk.png b/locale/widgets/uk.png index 0e92808..ba9d042 100644 Binary files a/locale/widgets/uk.png and b/locale/widgets/uk.png differ diff --git a/locale/widgets/zh-hans.png b/locale/widgets/zh-hans.png index 1c9d6e4..4f3c07b 100644 Binary files a/locale/widgets/zh-hans.png and b/locale/widgets/zh-hans.png differ diff --git a/locale/widgets/zh-hant.png b/locale/widgets/zh-hant.png index 650ca62..4f3c07b 100644 Binary files a/locale/widgets/zh-hant.png and b/locale/widgets/zh-hant.png differ diff --git a/scripts/generate_translations.sh b/scripts/generate_translations.sh index 39a2651..721cadc 100755 --- a/scripts/generate_translations.sh +++ b/scripts/generate_translations.sh @@ -1,27 +1,34 @@ cd .. -xgettext -L Python --package-name=RcGcDb -o locale/templates/discussion_formatters.pot src/formatters/discussions.py -xgettext -L Python --package-name=RcGcDb -o locale/templates/rc_formatters.pot src/formatters/rc.py +# Formatters +#find extensions/ -name '*.py' -print | xargs xgettext -L Python --package-name=RcGcDb --keyword=pgettext:1c,2 --keyword=npgettext:1c,2,3 -o "locale/templates/formatters.pot" src/api/util.py +for language in de pl pt-br hi ru uk zh-hans zh-hant fr es it + do + msgmerge -U locale/$language/LC_MESSAGES/formatters.po ~/Projects/RcGcDw/locale/$language/LC_MESSAGES/formatters.po +# msgmerge -U locale/$language/LC_MESSAGES/formatters.po locale/templates/formatters.pot +done + + xgettext -L Python --package-name=RcGcDb -o locale/templates/wiki.pot src/wiki.py -xgettext -L Python --package-name=RcGcDb -o locale/templates/discord.pot src/discord.py xgettext -L Python --package-name=RcGcDb -o locale/templates/misc.pot src/misc.py -declare -a StringArray=("discussion_formatters" "rc_formatters" "discord" "wiki" "misc") -for language in de pl pt-br hi ru uk zh-hans zh-hant +declare -a StringArray=("wiki" "misc") +for language in de pl pt-br hi ru uk zh-hans zh-hant fr es it do for file in ${StringArray[@]}; do msgmerge -U locale/$language/LC_MESSAGES/$file.po locale/templates/$file.pot done - msgmerge -o locale/$language/LC_MESSAGES/discussion_formatters.po ~/PycharmProjects/RcGcDw/locale/$language/LC_MESSAGES/discussion_formatters.po locale/$language/LC_MESSAGES/discussion_formatters.po - msgmerge -o locale/$language/LC_MESSAGES/rc_formatters.po ~/PycharmProjects/RcGcDw/locale/$language/LC_MESSAGES/rc_formatters.po locale/$language/LC_MESSAGES/rc_formatters.po - msgmerge -o locale/$language/LC_MESSAGES/wiki.po ~/PycharmProjects/RcGcDw/locale/$language/LC_MESSAGES/rc.po locale/$language/LC_MESSAGES/wiki.po - msgmerge -o locale/$language/LC_MESSAGES/misc.po ~/PycharmProjects/RcGcDw/locale/$language/LC_MESSAGES/misc.po locale/$language/LC_MESSAGES/misc.po - for file in ${StringArray[@]}; do + msgmerge -o locale/$language/LC_MESSAGES/wiki.po ~/Projects/RcGcDw/locale/$language/LC_MESSAGES/rc.po locale/$language/LC_MESSAGES/wiki.po + msgmerge -o locale/$language/LC_MESSAGES/wiki.po ~/Projects/RcGcDw/locale/$language/LC_MESSAGES/rcgcdw.po locale/$language/LC_MESSAGES/wiki.po + msgmerge -o locale/$language/LC_MESSAGES/misc.po ~/Projects/RcGcDw/locale/$language/LC_MESSAGES/misc.po locale/$language/LC_MESSAGES/misc.po + for file in wiki misc formatters + do msgfmt -o locale/$language/LC_MESSAGES/$file.mo locale/$language/LC_MESSAGES/$file.po done done -for language in locale/*/LC_MESSAGES +# for language in locale/*/LC_MESSAGES +for language in de pl pt-br hi ru uk zh-hans zh-hant fr es it do - wget https://weblate.frisk.space/widgets/rcgcdw/$(basename ${language//\/LC_MESSAGES/})/-/svg-badge.svg + wget https://translate.wikibot.de/widgets/rcgcdw/$(basename ${language//\/LC_MESSAGES/})/-/svg-badge.svg convert -background none svg-badge.svg locale/widgets/$(basename ${language//\/LC_MESSAGES/}).png rm svg-badge.svg done diff --git a/src/i18n.py b/src/i18n.py index 539238c..5735cfa 100644 --- a/src/i18n.py +++ b/src/i18n.py @@ -3,11 +3,15 @@ from collections import defaultdict logger = logging.getLogger("rcgcdb.i18n") supported_languages = ('de', 'hi', 'pl', 'pt-br', 'ru', 'zh-hans', 'zh-hant', 'es') -translated_files = ('redaction', 'misc', 'formatters') +translated_files = ('wiki', 'misc', 'formatters') langs = defaultdict(dict) for lang in supported_languages: for file in translated_files: - langs[lang][file] = gettext.translation(file, localedir='locale', languages=[lang]) + try: + langs[lang][file] = gettext.translation(file, localedir='locale', languages=[lang]) + except FileNotFoundError: + logger.error(f"Language: {lang}") + raise for file in translated_files: langs["en"][file] = gettext.NullTranslations() diff --git a/src/misc.py b/src/misc.py index 56527e0..f62a5b2 100644 --- a/src/misc.py +++ b/src/misc.py @@ -160,19 +160,19 @@ class ContentParser(HTMLParser): if self.current_tag == "ins" and self.ins_length <= 1000: self.ins_length += len("**" + data + "**") if self.ins_length <= 1000: - self.last_ins = self.last_ins + "**" + data + "**" + self.last_ins = self.last_ins or "" + "**" + data + "**" if self.current_tag == "del" and self.del_length <= 1000: self.del_length += len("~~" + data + "~~") if self.del_length <= 1000: - self.last_del = self.last_del + "~~" + data + "~~" + self.last_del = self.last_del or "" + "~~" + data + "~~" if self.current_tag == "tda" and self.ins_length <= 1000: self.ins_length += len(data) if self.ins_length <= 1000: - self.last_ins = self.last_ins + data + self.last_ins = self.last_ins or "" + data if self.current_tag == "tdd" and self.del_length <= 1000: self.del_length += len(data) if self.del_length <= 1000: - self.last_del = self.last_del + data + self.last_del = self.last_del or "" + data def handle_endtag(self, tagname): self.current_tag = "" diff --git a/src/wiki.py b/src/wiki.py index 2475904..47e8620 100644 --- a/src/wiki.py +++ b/src/wiki.py @@ -474,13 +474,13 @@ async def rc_processor(wiki: Wiki, change: dict, changed_categories: dict, displ LinkParser.feed(change.get("parsedcomment", "")) parsed_comment = LinkParser.new_string else: - parsed_comment = context._("~~hidden~~") + parsed_comment = langs[display_options.lang]["wiki"].gettext("~~hidden~~") if not parsed_comment and context.message_type == "embed" and settings["appearance"].get("embed", {}).get( "show_no_description_provided", True): - parsed_comment = context._("No description provided") + parsed_comment = langs[display_options.lang]["wiki"].gettext("No description provided") context.set_parsedcomment(parsed_comment) if "userhidden" in change: - change["user"] = context._("hidden") + change["user"] = langs[display_options.lang]["wiki"].gettext("hidden") if change.get("ns", -1) in settings.get("ignored_namespaces", ()): return if change["type"] in ["edit", "new"]: