migrate strings with trailing newlines to fluent

This commit is contained in:
Damien Elmes 2020-02-27 20:32:57 +10:00
parent f4d38f579d
commit 43f5d13ed6
11 changed files with 45 additions and 39 deletions

View File

@ -26,7 +26,7 @@ from anki.lang import _, ngettext
from anki.media import MediaManager
from anki.models import ModelManager, NoteType, Template
from anki.notes import Note
from anki.rsbackend import RustBackend
from anki.rsbackend import TR, RustBackend
from anki.sched import Scheduler as V1Scheduler
from anki.schedv2 import Scheduler as V2Scheduler
from anki.tags import TagManager
@ -580,9 +580,11 @@ select group_concat(ord+1), count(), flds from cards c, notes n
where c.nid = n.id and c.id in %s group by nid"""
% ids2str(cids)
):
rep += _("Empty card numbers: %(c)s\nFields: %(f)s\n\n") % dict(
c=ords, f=flds.replace("\x1f", " / ")
rep += self.tr(
TR.EMPTY_CARDS_CARD_LINE,
**{"card-numbers": ords, "fields": flds.replace("\x1f", " / ")},
)
rep += "\n\n"
return rep
# Field checksums and sorting fields

View File

@ -28,6 +28,7 @@ from anki.httpclient import HttpClient
from anki.lang import _, ngettext
from aqt.qt import *
from aqt.utils import (
TR,
askUser,
getFile,
isWin,
@ -40,6 +41,7 @@ from aqt.utils import (
showInfo,
showWarning,
tooltip,
tr,
)
@ -205,16 +207,11 @@ class AddonManager:
__import__(addon.dir_name)
except:
showWarning(
_(
"""\
An add-on you installed failed to load. If problems persist, please \
go to the Tools>Add-ons menu, and disable or delete the add-on.
When loading '%(name)s':
%(traceback)s
"""
tr(
TR.ADDONS_FAILED_TO_LOAD,
name=addon.human_name(),
traceback=traceback.format_exc(),
)
% dict(name=addon.human_name(), traceback=traceback.format_exc())
)
def onAddonsDialog(self):

View File

@ -128,7 +128,7 @@ your system's temporary folder may be incorrect."""
addons = [
mw.addonManager.addonName(i) for i in dict.fromkeys(reversed(matches))
]
txt = _("""Add-ons possibly involved: {}\n""")
# highlight importance of first add-on:
addons[0] = "<b>{}</b>".format(addons[0])
return txt.format(", ".join(addons))
addons_str = ", ".join(addons)
return tr(TR.ADDONS_POSSIBLY_INVOLVED, addons=addons_str) + "\n"

View File

@ -18,6 +18,7 @@ from anki.lang import _, ngettext
from aqt import AnkiQt, gui_hooks
from aqt.qt import *
from aqt.utils import (
TR,
askUser,
getFile,
getOnlyText,
@ -26,6 +27,7 @@ from aqt.utils import (
showText,
showWarning,
tooltip,
tr,
)
@ -196,7 +198,7 @@ you can enter it here. Use \\t to represent tab."""
showUnicodeWarning()
return
except Exception as e:
msg = _("Import failed.\n")
msg = tr(TR.IMPORTING_FAILED_DEBUG_INFO) + "\n"
err = repr(str(e))
if "1-character string" in err:
msg += err
@ -360,7 +362,7 @@ def importFile(mw, file):
if msg == "'unknownFormat'":
showWarning(_("Unknown file format."))
else:
msg = _("Import failed. Debugging info:\n")
msg = tr(TR.IMPORTING_FAILED_DEBUG_INFO) + "\n"
msg += str(traceback.format_exc())
showText(msg)
return
@ -405,7 +407,7 @@ Unable to import from a read-only file."""
)
)
else:
msg = _("Import failed.\n")
msg = tr(TR.IMPORTING_FAILED_DEBUG_INFO) + "\n"
msg += str(traceback.format_exc())
showText(msg)
else:

View File

@ -42,6 +42,7 @@ from aqt.qt import sip
from aqt.taskman import TaskManager
from aqt.theme import theme_manager
from aqt.utils import (
TR,
askUser,
checkInvalidFilename,
getFile,
@ -55,6 +56,7 @@ from aqt.utils import (
showText,
showWarning,
tooltip,
tr,
)
install_pylib_legacy()
@ -439,16 +441,7 @@ close the profile or restart Anki."""
return self._loadCollection()
except Exception as e:
showWarning(
_(
"""\
Anki was unable to open your collection file. If problems persist after \
restarting your computer, please use the Open Backup button in the profile \
manager.
Debug info:
"""
)
+ traceback.format_exc()
tr(TR.ERRORS_UNABLE_OPEN_COLLECTION) + "\n" + traceback.format_exc()
)
# clean up open collection if possible
if self.col:

View File

@ -19,11 +19,11 @@ import anki.lang
import aqt.forms
import aqt.sound
from anki.db import DB
from anki.lang import _
from anki.lang import _, without_unicode_isolation
from anki.utils import intTime, isMac, isWin
from aqt import appHelpSite
from aqt.qt import *
from aqt.utils import locale_dir, showWarning
from aqt.utils import TR, locale_dir, showWarning, tr
metaConf = dict(
ver=0,
@ -375,16 +375,9 @@ create table if not exists profiles
self.create(_("User 1"))
p = os.path.join(self.base, "README.txt")
open(p, "w", encoding="utf8").write(
_(
"""\
This folder stores all of your Anki data in a single location,
to make backups easy. To tell Anki to use a different location,
please see:
%s
"""
without_unicode_isolation(
tr(TR.PROFILES_FOLDER_README, link=appHelpSite + "#startupopts")
)
% (appHelpSite + "#startupopts")
)
# Default language

6
qt/ftl/addons.ftl Normal file
View File

@ -0,0 +1,6 @@
addons-possibly-involved = Add-ons possibly involved: { $addons }
addons-failed-to-load =
An add-on you installed failed to load. If problems persist, please go to the Tools>Add-ons menu, and disable or delete the add-on.
When loading '{$name}':
{$traceback}

View File

@ -36,4 +36,7 @@ errors-accessing-db =
- Your hard disk may have errors.
It's a good idea to run Tools>Check Database to ensure your collection is not corrupt.
errors-unable-open-collection =
Anki was unable to open your collection file. If problems persist after restarting your computer, please use the Open Backup button in the profile manager.
Debug info:

6
qt/ftl/profiles.ftl Normal file
View File

@ -0,0 +1,6 @@
profiles-folder-readme =
This folder stores all of your Anki data in a single location,
to make backups easy. To tell Anki to use a different location,
please see:
{$link}

View File

@ -0,0 +1,3 @@
empty-cards-card-line =
Empty card numbers: {$card-numbers}
Fields: {$fields}

1
rslib/ftl/importing.ftl Normal file
View File

@ -0,0 +1 @@
importing-failed-debug-info = Import failed. Debugging info: