ALToolbox
This repository is used to host small Python modules, widgets, and JavaScript web components js files that enhance Docassemble interviews. These modules were built as part of the Suffolk University Law School LIT Lab's Document Assembly Line project. They are placed here rather than in https://github.com/SuffolkLitLab/docassemble-AssemblyLine because we believe these small components can easily be used by anyone, regardless of whether they use any other code from the Document Assembly Line project.
If you want to add a small function to this project, consider adding it to the existing misc.py to avoid creating too many module files.
Documentation
Read the documentation for the functions and components to learn how to use these components in your own Docassemble projects.
Translating strings inside JavaScript
Docassemble translates anything that reaches Python through word(), but JavaScript
running in the browser has no way to reach that catalog, so strings in custom datatypes
and small widgets tend to stay hardcoded in English.
ALToolbox adds an endpoint, /al_translations.json?lang=es, that returns the word()
catalog for a language, and a script that puts it behind _():
include:
- docassemble.ALToolbox:translation_strings.yml
Then, in your JavaScript:
_("Copied!") // "¡Copiado!"
_("You have entered %d characters.", count) // "Ha escrito 42 caracteres."
_("%1$s of %2$s", done, total) // positional, so a translation can reorder
_("100%% sure") // "%%" is a literal percent sign
alTranslate() is the same function under a less collision-prone name. _ is only
assigned if nothing else has claimed it, so an interview that loads lodash or underscore
keeps its own _.
Adding translations
Write a word translation file and list it under words: in your server configuration —
the same mechanism docassemble already uses for word():
# docassemble/yourpackage/data/sources/yourpackage_words.yml
es:
Copied!: ¡Copiado!
You have entered %d characters.: Ha escrito %d caracteres.
# in the docassemble configuration
words:
- docassemble.ALToolbox:data/sources/altoolbox_words.yml
- docassemble.yourpackage:data/sources/yourpackage_words.yml
For translations that come from somewhere other than a file, add_translations() adds
them to the same catalog at runtime:
code: |
add_translations("es", {"Copied!": "¡Copiado!"})
Lookups try an exact match first, then one that ignores surrounding whitespace,
capitalization and trailing punctuation, restoring the source string's capitalization and
punctuation on the way out. So a catalog entry for copied will still translate
_("Copied!").
What to expect
The catalog is fetched once and kept in localStorage, keyed by language, so _()
resolves synchronously on every page load after the first. On the very first load of a
language the catalog is still in flight and _() returns the English source; listen for
the alTranslationsLoaded event on window if you need to redraw when it arrives.
Docassemble loads every script at the end of the body, so _ exists from daPageLoad
onward — which is where interview JavaScript normally does its work anyway. An inline
<script> in a subquestion runs before that, so wrap it:
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("greeting").textContent = _("Hello");
});
The endpoint is unauthenticated and identical for every user of a language — it exposes
the server's configured word() catalog for that language (which may include arbitrary
phrases from installed packages). translation_strings.translate() is
Run translation_strings_demo.yml to see it working.
Suffolk LIT Lab Document Assembly Line
The Assembly Line Project is a collection of volunteers, students, and institutions who joined together during the COVID-19 pandemic to help increase access to the court system. Our vision is mobile-friendly, easy to use guided online forms that help empower litigants to access the court remotely.
Our signature project is CourtFormsOnline.org.
We designed a step-by-step, assembly line style process for automating court forms on top of Docassemble and built several tools along the way that you can use in your home jurisdiction.
This package contains runtime code and pre-written questions to support authoring robust, consistent, and attractive Docassemble interviews that help complete court forms.
Read more on our documentation page.
Related repositories
- https://github.com/SuffolkLitLab/docassemble-AssemblyLine
- https://github.com/SuffolkLitLab/docassemble-ALWeaver
- https://github.com/SuffolkLitLab/docassemble-ALMassachusetts
- https://github.com/SuffolkLitLab/docassemble-MassAccess
- https://github.com/SuffolkLitLab/docassemble-ALThemeTemplate
- https://github.com/SuffolkLitLab/EfileProxyServer
Contributors:
- @plocket
- @nonprofittechy
- @purplesky2016
- @brycestevenwilley
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docassemble_altoolbox-0.19.0.tar.gz.
File metadata
- Download URL: docassemble_altoolbox-0.19.0.tar.gz
- Upload date:
- Size: 344.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f0891c5453f543066433d64056ead2a61fe76f17608eca2b89b474b2a7103ee
|
|
| MD5 |
f6ab06cba76edf29e347e79bd7a88090
|
|
| BLAKE2b-256 |
2395b942dae55da3fb7385b4da34ed9b7cd240f9f6f0ddf6b9481b2cb9675827
|
Provenance
The following attestation bundles were made for docassemble_altoolbox-0.19.0.tar.gz:
Publisher:
publish.yml on SuffolkLITLab/docassemble-ALToolbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docassemble_altoolbox-0.19.0.tar.gz -
Subject digest:
9f0891c5453f543066433d64056ead2a61fe76f17608eca2b89b474b2a7103ee - Sigstore transparency entry: 2488017474
- Sigstore integration time:
-
Permalink:
SuffolkLITLab/docassemble-ALToolbox@acbb22a0c5c7cffb3b4d1a1ca77971d047791639 -
Branch / Tag:
refs/tags/v0.19.0 - Owner: https://github.com/SuffolkLITLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@acbb22a0c5c7cffb3b4d1a1ca77971d047791639 -
Trigger Event:
push
-
Statement type:
File details
Details for the file docassemble_altoolbox-0.19.0-py3-none-any.whl.
File metadata
- Download URL: docassemble_altoolbox-0.19.0-py3-none-any.whl
- Upload date:
- Size: 379.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
957cab93658072623c69fb6866af61d6a0d1bb7715571196b8f8242d2e124b2b
|
|
| MD5 |
64d5050e84564f4a9253847aee3dbbab
|
|
| BLAKE2b-256 |
48d367d4354548f9889d66efd24c4e71153384a2b377387cb8736038b90b2348
|
Provenance
The following attestation bundles were made for docassemble_altoolbox-0.19.0-py3-none-any.whl:
Publisher:
publish.yml on SuffolkLITLab/docassemble-ALToolbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docassemble_altoolbox-0.19.0-py3-none-any.whl -
Subject digest:
957cab93658072623c69fb6866af61d6a0d1bb7715571196b8f8242d2e124b2b - Sigstore transparency entry: 2488017509
- Sigstore integration time:
-
Permalink:
SuffolkLITLab/docassemble-ALToolbox@acbb22a0c5c7cffb3b4d1a1ca77971d047791639 -
Branch / Tag:
refs/tags/v0.19.0 - Owner: https://github.com/SuffolkLITLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@acbb22a0c5c7cffb3b4d1a1ca77971d047791639 -
Trigger Event:
push
-
Statement type: