* FIX lang selection resetting to en_US for some langs
Fixes https://forums.ankiweb.net/t/anki-25-01-beta/54490/17?u=anon_0000.
# Issue
Set a hand full of certain languages in the preferences screen and see that the translations have been applied after reboot. The language selection in preferences wrongly shows en_US though, not the current active language. If you wanted to switch to `en_US` in this case, then you'd have to first switch to a working language (like de_DE) and then switch to en_US.
# Solution
`anki/qt/aqt/preferences.py` has the functions `setup_language()` and `current_lang_index()`. I noticed that it defaults to en_US, if the language is not in `compatMap` and it couldn’t return the index of the current language. No idea if this code is faulty but I headed over to `anki/pylib/anki/lang.py` afterwards.
Here, in `compatMap`, I added e.g. `"la": "la_LA"`. I knew the code since I could get it with `print("––– lang is ", lang)` in `preferences.py` (`current_lang_index()` retrieves `la` for latin).
After adding those code changes from my PR, the problem for those selected languages had gone away.
No idea if that's best practices though or if something else should be fixed instead.
* UPDATE CONTRIBUTORS adding myself to the list
* Update to FSRS-rs v1.3.2
* add fsrs_short_term_with_steps_enabled to config
* ./ninja fix:minilints
* fix defaults_for_testing
* if current parameters are invalid, skip comparison
fix#3498
* fix redundant_field_names
* cargo clippy --fix
* Update to FSRS-rs v1.3.3
* Update to FSRS-rs v1.3.4
* Avoid an extra config lookup on each card answer (dae)
* Feat/export dataset for research
* add comment
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
* target_path is required
* format
* improve efficiency to look up parent_id
* move `use` down
* add get_revlogs API
* fix tooltipText of ReviewsGraph
the style of true-retention shouldn't affect the style of tooltipText of ReviewsGraph
* More verbose wording (dae)
* typeanswer: fix cleanup
Fix: Add prepare_expected back in for the 'nothing typed' & 'correctly typed' cases. This also makes expected_original redundant again.
Style: %s/provided/typed/g
Style: rename one ch → c
Testcase: whitespace_is_trimmed: added a check for the "correctly typed" path and renamed it to tags_removed (there's no whitespace?)
Testcase: empty_input_shows_as_code: changed to also check that tags get trimmed
* [type:nc] – ignores combining characters
Adds a comparison variant to [type] which ignores when combining characters of the expected field are missing from the provided input. It still shows these characters in the 'expected' line for reference.
It's useful for languages with e.g. diacritics that are required for reference (such as in dictionaries), but rarely actually learned or used in everyday writing. Among these languages: Arabic, Hebrew, Persian, Urdu.
The bool 'combining' controls it as new final parameter of both relevant compare_answer functions. On the Python side, it's set to true by default.
Use on the note templates: [type:nc:field] (only the front needs to include :nc)
This also removes the need to have both variants of words/sentences present as separate fields, to show them redundantly, etc.
* typeanswer: simplify by using nfkd throughout
Requires adjusting two testcases, but both render exactly the same in Anki itself.
On NFC vs. NKFD: https://stackoverflow.com/a/77432079
* typeanswer: 'simplify' by removing normalize_typed (requiring a bool parameter)
I'd prefer to keep this extra method.
* typeanswer: micro-optimize vectors
Should get rid of most relocations, at the expense of over-allocating.
On Vec's (String's) behavior: https://stackoverflow.com/a/72787776
* Mark `combining` as private
typeCorrect is not marked as private either, but we can at least do
the right thing for newly-added code.
* Revert "typeanswer: micro-optimize vectors"
This reverts commit 9fbacbfd19.
* Revert "typeanswer: 'simplify' by removing normalize_typed (requiring a bool parameter)"
This reverts commit df2dd3394e.
* Bump Python deps
Primarily for flask-cors CVE
* Bump TS deps; pin license checker
Current checker is missing the binary
https://github.com/RSeidelsohn/license-checker-rseidelsohn/issues/118
* Update Rust deps
Hyper and axum are held back as we currently make use of the older
http library that reqwest pulls in
* Empty cards is undoable
If there was a reason for this operation not to be undoable, I can't easily guess it. My main hyposhesis was that the number of deleted card may be too big. But I realized that deleting a deck is undoable and may delete as many note.
As you may know, I realized that only the undoable operations triggered notification in AnkiDroid that we may have to update the UI. And while I just wanted to trigger more notifications, some reviewers thought it would be nicer if the operation were returning a OpChanges. So here it's done. If you would please consider merging it.
I decided to introduce a new string because the closest strings I could find currently are "Empty cards..." and the trailing commas don't seem nice in "undo". And the title, which we may not be able to reuse in all language
* Don't count cards that have already been removed (dae)
* start of load balancer
* add configuration options; option to load balance per deck
* formatting
* clippy
* add myself to contributors
* cleanup
* cargo fmt
* copyright header on load_balancer.rs
* remove extra space
* more formatting
* python formatting
* ignore this being None
only doing this cause python has awful lambdas and can't
loop in a meaningful way without doing this
* only calculate notes on each day if we are trying to avoid siblings
* don't fuzz intervals if the load balancer is enabled
* force generator to eval so this actually happens
* load balance instead of fuzzing, rather than in addition to
* use builtin fuzz_bounds rather than reinvent something new
* print some debug info on how its load balancing
* clippy
* more accurately load balance only when we want to fuzz
* incorrectly doublechecking the presence of the load balancer
* more printfs for debugging
* avoid siblings -> disperse siblings
* load balance learning graduating intervals
* load balancer: respect min/max intervals; graduating easy should be at least +1 good
* filter out after-days under minimum interval
* this is an inclusive check
* switch load balancer to caching instead of on the fly calculation
* handle case where load balancer would balance outside of its bounds
* disable lb when unselecting it in preferences
* call load_balancer in StateContext::with_review_fuzz instead of next to
* rebuild load balancer when card queue is rebuilt
* remove now-unused configuration options
* add note option to notetype to enable/disable sibling dispersion
* add options to exclude decks from load balancing
* theres a lint checking that the link actually exists so I guess I'll add the anchor back in later?
* how did I even update this
* move load balancer to cardqueue
* remove per-deck balancing options
* improve determining whether to disperse siblings when load balancing
* don't recalculate notes on days every time
* remove debug code
* remove all configuration; load balancer enabled by default; disperse siblings if bury_reviews is set
* didn't fully remove caring about decks from load balancer sql query
* load balancer should only count cards in the same preset
* fuzz interval if its outside of load balancer's range
* also check minimum when bailing out of load balancer
* cleanup; make tests happy
* experimental weight-based load balance fuzzing
* take into account interval when weighting as it seems to help
* if theres no cards the interval weight is just 1.0
* make load balancer disableable through debug console
* remove debug prints
* typo
* remove debugging print
* explain a bit how load balancer works
* properly balance per preset
* use inclusive range rather than +1
* -1 type cast
* move type hint somewhere less ugly; fix comment typo
* Reuse existing deck list from parent function (dae)
Minor optimisation
* Add AnkiHub section to preferences screen
* Add short intro for AnkiWeb and AnkiHub to syncing section
* Add AnkiHub login screen
* Implement login methods in backend
* Set minimum dialog width
* Add missing colon
* Respect the ANKIHUB_APP_URL env var
This is used by the add-on.
* Simplify login error reporting
* Fix from_prefs_screen not passed to subcall
* Add missing ankihub_pb2 import
* Install AnkiHub add-on after sign-in
* Avoid .exec()
* Update ftl/core/sync.ftl
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
* Split translation string
* Support login by username/email
* Fix entered username/email not being passed back to on_done
* Remove unused import
* Move to 'Third-party services' section
* Tweak login dialog's heading
* Remove 'third-party' from intro text
* Tweak copy
* Prefix profile keys
* Tweak strings
* Remove description from login dialog
* Remove signup links
* Clear credentials in ankihub_logout()
* Call .adjustSize()
* Title Case
* Add padding to third-party services, and fix tab order from other PR
* fix: except only non-system-exiting exceptions
see https://youtu.be/zrVfY9SuO64
* chore: add myself to CONTRIBUTORS file
* refactor: explicitly specify possible exceptions
If an exception is not an Exception, there are only three options left.
see https://docs.python.org/3/library/exceptions.html#exception-hierarchy
* refactor: use BaseException for fallback
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
* chore: add myself to contributors
* refactor: rename variables of tuple
* refactor: rename function argument
* refactor: use function to get index of language
* refactor: replace for-loop
* refactor: use variable
* refactor: assert values are not None
To satisfy the type checker.
* refactor: change generator expression to for-loop
* refactor: fix type annotation
* fix: properly check if argument is None
Don't use Boolean expressions to implement a default value.
* fix: ensure that 'model' is not None
Don't use exceptions to control the flow.
* refactor: simplify if-else construct
* chore: add myself to CONTRIBUTORS file
* refactor: use newer type hints for Union/Optional
* refactor: fix deprecated type annotations
use collections.abc rather than typing
* refactor: use lower letter type annotations
* style: reformat with black
* refactor: remove unused imports
* refactor: add missing imports for type hints
* fixup! refactor: use newer type hints for Union/Optional
* fix: add missing imports for type annotations
* fixup! refactor: use newer type hints for Union/Optional
* fixup! style: reformat with black
* refactor: fix remaining imports re: type hints
* Add a preference to toggle LaTeX generation
* Fix test
* Remove LaTeX security restrictions
* Show existing LaTeX images regardless of preference
* Lift config check out of loop (dae)
* Shift option to review settings; display warning when disabled (dae)
* Update to latest Node LTS
* Add sveltekit
* Split tslib into separate @generated and @tslib components
SvelteKit's path aliases don't support multiple locations, so our old
approach of using @tslib to refer to both ts/lib and out/ts/lib will no
longer work. Instead, all generated sources and their includes are
placed in a separate out/ts/generated folder, and imported via @generated
instead. This also allows us to generate .ts files, instead of needing
to output separate .d.ts and .js files.
* Switch package.json to module type
* Avoid usage of baseUrl
Incompatible with SvelteKit
* Move sass into ts; use relative links
SvelteKit's default sass support doesn't allow overriding loadPaths
* jest->vitest, graphs example working with yarn dev
* most pages working in dev mode
* Some fixes after rebasing
* Fix/silence some svelte-check errors
* Get image-occlusion working with Fabric types
* Post-rebase lock changes
* Editor is now checked
* SvelteKit build integrated into ninja
* Use the new SvelteKit entrypoint for pages like congrats/deck options/etc
* Run eslint once for ts/**; fix some tests
* Fix a bunch of issues introduced when rebasing over latest main
* Run eslint fix
* Fix remaining eslint+pylint issues; tests now all pass
* Fix some issues with a clean build
* Latest bufbuild no longer requires @__PURE__ hack
* Add a few missed dependencies
* Add yarn.bat to fix Windows build
* Fix pages failing to show when ANKI_API_PORT not defined
* Fix svelte-check and vitest on Windows
* Set node path in ./yarn
* Move svelte-kit output to ts/.svelte-kit
Sadly, I couldn't figure out a way to store it in out/ if out/ is
a symlink, as it breaks module resolution when SvelteKit is run.
* Allow HMR inside Anki
* Skip SvelteKit build when HMR is defined
* Fix some post-rebase issues
I should have done a normal merge instead.
* update fsrs to 0.4.5
* update to fsrs 0.4.6
* add benchmark API
* update fsrs to 0.5.0
* cargo fmt
* ./ninja fix:minilints
* ./ninja format
* Add a brief comment about the new method (dae)
* Update JS deps
* Update semver-compat Rust deps
* Update some semver-incompat Rust deps
- hyper/axum held back because reqwests is not ready
- rusqlite held back due to burn-rs incompat version
- wiremock held back due to compile issue
* pylint wants changes to our _rsbridge.pyi
* Update Python deps
Also solves a security warning in orjson
Reformat with latest black
* adds log module
* enable logging in the app
* adds a getLogger method to AddonManager
* change log level depending on ANKIDEV
* fix undefined module variable
* - fix addons log file path
- remove a breakpoint leftover
set the addons log files under pm.addonFolder()/NNNNNN/user_files/logs/NNNNNN.log
* fix path bug
* move log closing handling into AddonManager deleteAddon/backupUserFiles methods
* logging module level import
fix undefined variable in backupUserFiles
* pretty format log records
* move MediaServer log into logging
* update CONTRIBUTORS
* documentation cleanup
* capture warnings into log messages
fix waitress verbosity
* remove record_factory function
* add get_logger method alias to getLogger in AddonManager
switch to TimedRotatingFileHandler handler
fix minor typo
* set main log level to DEBUG if ANKIDEV is not 0 (or unset)
added two new methods to AddonManager addon_get_logger/addon_toggle_log_level
* add new find_logger_output to AddonManager
* move logs under pm.base
* change log output
* update addonmanager getlogger
* Format imports
* Refactor logging set-up slightly and tweak docstring
* Remove obsolete log closing statements
As logs are no longer stored in user_files, we do not need to close their handlers
* Refactor and try to simplify log module
* Remove demo code
* Refactor and update add-on manager logging API
* Simplify writing unit tests for add-ons that use logging
Loggers are likely to be also employed in non UI code, so it seems like a good idea to decouple them from requiring a running Anki instance to work (thus freeing add-on authors from the need to mock Anki APIs in their tests).
* Fix arguments and drop obsolete inline instructions
Lets add a section on logging to the add-on docs instead
* Drop unnecessary import
* Supply logging basicConfig force option by default
Until we change the module import order and thus ensure that `log` is always evaluated before third-party dependencies have a chance to initialize the root logger, `force` is non-optional.
* Fix formatting and type errors
* Restore mediasrv type ignore comments
* Add note on prefix API stability
* Consistently use addon_from_module in new code
* Use logFolder rather than profileFolder
* Adjust method name for PEP8
* Change loggerDict access path, satisfying pylint
* Drop unused import and use lazy % formatting
* lint fix
* refactor .log_folder -> .addon_logs
store anki.log under logdir
* Fix method name (dae)
* Disable file-based logging in the backend (dae)
I have never found this useful, and it logs nothing by default, so
creating/opening the file is a waste. Removing it also ensures that
addon_logs() is solely used for add-ons.
---------
Co-authored-by: Glutanimate <5459332+glutanimate@users.noreply.github.com>
* Ignore rescheduled cards in old stats page
Rescheduled cards are not actual reviews. So, including them in Cards Studied Today is inappropriate.
* Simplify SQL query
* Fix Answer Buttons graph
* Fix error
* Potentially fix error