Commit graph

38 commits

Author SHA1 Message Date
Damien Elmes
8e5e22e21d update Rust deps 2021-12-03 20:35:53 +10:00
Damien Elmes
f3aebcc786 update to Rust 1.57 + latest rules_rust 2021-12-03 20:35:52 +10:00
Damien Elmes
695871e66c Fix latest Rusqlite on Windows
https://github.com/bazelbuild/rules_rust/pull/1025
2021-11-19 10:44:02 +10:00
Damien Elmes
89b043c319 roll rusqlite back due to Windows breakage 2021-11-18 21:39:23 +10:00
Damien Elmes
c5c41759b4 update Rust deps 2021-11-18 20:58:41 +10:00
Damien Elmes
1ac84d9454 update to edition 2021 2021-11-18 20:51:10 +10:00
RumovZ
5c64aadb7a Garbage collect unused Fluent strings (#1482)
* Canonify import of i18n module

Should always be imported as `tr`, or `tr2` if there is a name collision
(Svelte).

* Add helper for garbage collecting ftl strings

Also add a serializer for ftl asts.

* Add helper for filter-mapping `DirEntry`s

* Fix `i18n_helpers/BUILD.bazel`

* run cargo-raze

* Refactor `garbage_collection.rs`

- Improve helper for file iterating
- Remove unused terms as well
- Fix issue with checking for nested messages by switching to a regex-
based approach (which runs before deleting)
- Some more refactorings and lint fixes

* Fix lints in `serialize.rs`

* Write json pretty and sorted

* Update `serialize.rs` and fix header

* Fix doc and remove `dbg!`

* Add binaries for ftl garbage collection

Also relax type constraints and strip debug tests.

* add rust_binary targets for i18n helpers (dae)

* add scripts to update desktop usage/garbage collect (dae)

Since we've already diverged from 2.1.49, we won't gain anything
from generating a stable json just yet. But once 2.1.50 is released,
we should run 'ftl/update-desktop-usage.sh stable'.

* add keys from AnkiMobile (dae)

* Mention caveats in `remove-unused.sh`
2021-11-12 18:19:01 +10:00
Damien Elmes
dae1854106 update Rust deps with cargo-raze 0.13.0 2021-10-26 08:16:40 +10:00
Damien Elmes
79aa52c082 update Rust deps 2021-10-02 20:42:03 +10:00
Damien Elmes
bc7c43ac67 avoid extra allocation in replacement 2021-10-01 14:43:38 +10:00
abdo
4d3f2c0232 Strip isolation chars from filenames in Check Media screen 2021-09-27 22:15:37 +03:00
Damien Elmes
e37a0844ae fix new clippy warning 2021-08-22 15:32:46 +10:00
Damien Elmes
795afb7068 update most rust deps; skip rusqlite 2021-06-25 15:35:25 +10:00
Damien Elmes
ff095ed57b fix clippy lints for latest Rust 2021-06-21 13:09:36 +10:00
Damien Elmes
596e37cabc update Rust deps 2021-06-16 16:10:57 +10:00
Damien Elmes
d76ef9cde5 update Rust deps
- tokio 1.0
- updated reqwest, thanks to Rumo
- other minor dep updates

the reqwest build file has been split into two, as it was awkward
to manually update the combined file, and the platform gate is now
on the target in rslib/
2021-04-27 22:18:12 +10:00
Damien Elmes
77c0f0effd add missing copyright headers to *.rs 2021-04-13 18:59:16 +10:00
Damien Elmes
a8af070f9a update find&replace, and remove perform_op() 2021-04-06 17:07:38 +10:00
Damien Elmes
990397880f fix changes to .ftl and .proto files not being picked up by 'cargo check' 2021-04-01 22:29:54 +10:00
Damien Elmes
5ef618d8fa add a few more ftl type hints 2021-03-29 15:55:15 +10:00
Damien Elmes
3dee049128 gate qt template inclusion on extra_ftl_root name
Bazel was not noticing that the build script needs to be recompiled
when the qt templates flag was changed.
2021-03-29 13:17:38 +10:00
Damien Elmes
2338998304 update to the latest rules_rust + security framework update 2021-03-27 19:28:19 +10:00
Damien Elmes
0a4bcd3faa update Rust deps 2021-03-27 14:47:16 +10:00
Damien Elmes
c9eddfabac add string/number distinction to generated Rust methods 2021-03-27 14:31:23 +10:00
Damien Elmes
66d84336d7 update to latest Fluent 2021-03-27 13:24:11 +10:00
Damien Elmes
9a7f0f9f5d i18n->tr in rslib/ to match Python/TS code 2021-03-27 12:09:51 +10:00
Damien Elmes
4676d2f3b1 drop the legacy enum from rslib, and pass separate module/message idx 2021-03-27 11:56:31 +10:00
Damien Elmes
d7005803bc update 1 arg tr strings in rslib 2021-03-27 10:39:53 +10:00
Damien Elmes
0421ae3e6d preserve variable order when extracting from ftl files 2021-03-27 09:09:13 +10:00
Damien Elmes
26d265ce08 write methods into generated.rs 2021-03-26 23:07:18 +10:00
Damien Elmes
0006a385e1 allow js to request specific i18n modules
Brings the payload on the congrats page with a non-English language
down from about 150k to 15k
2021-03-26 21:43:36 +10:00
Damien Elmes
0e50259e6b update TR references with args in *.ts; fix average answer time 2021-03-26 19:10:39 +10:00
Damien Elmes
d7bef83f98 add types to some more Fluent variables 2021-03-26 16:52:54 +10:00
Damien Elmes
afdca58e31 declare variables with some common names as int instead of a union 2021-03-26 16:33:53 +10:00
Damien Elmes
c52bafd1ef delimit variables in docstrings to make them easier to read 2021-03-26 14:38:30 +10:00
Damien Elmes
ee2d3500e5 catch variables only used in plural selection 2021-03-26 14:20:44 +10:00
Damien Elmes
834a7217d6 embed strings.json into write_json.rs
It appears that including the build script as a dependency is not
enough to make the file available at runtime, so the build breaks
if ts/ is built first.
2021-03-26 09:55:21 +10:00
Damien Elmes
0c63a7c8c4 rework translation handling
Instead of generating a fluent.proto file with a giant enum, create
a .json file representing the translations that downstream consumers
can use for code generation.

This enables the generation of a separate method for each translation,
with a docstring that shows the actual text, and any required arguments
listed in the function signature.

The codebase is still using the old enum for now; updating it will need
to come in future commits, and the old enum will need to be kept
around, as add-ons are referencing it.

Other changes:

- move translation code into a separate crate
- store the translations on a per-file/module basis, which will allow
us to avoid sending 1000+ strings on each JS page load in the future
- drop the undocumented support for external .ftl files, that we weren't
using
- duplicate strings in translation files are now checked for at build
time
- fix i18n test failing when run outside Bazel
- drop slog dependency in i18n module
2021-03-26 09:41:32 +10:00