You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/components/AssemblyLine/translation.md
+55-25Lines changed: 55 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,17 @@ all Assembly Line special variables, see [Special variables](magic_variables.md)
88
88
*`enable_al_language`: defaults to True, turning it off can partially ensure the language system in AssemblyLine doesn't interfere with existing language systems. It should be relatively easy for authors to migrate to this new system though.
89
89
*`al_user_default_language`: can be controlled by interview author, this determines the language when the user makes no selection of their own. Defaults to "en".
90
90
*`al_interview_languages`: a list of language codes, presumably ISO-639-1 (Alpha-2), like ["en","es"] etc. The Assembly Line also contains a translation of several common language codes into the native-language version of the language (e.g., `es` is translated as `Español`).
91
-
*`al_user_language`: normally set via a dropdown menu or passed as a URL argument, this stores the user's current selected language
91
+
*`al_user_language`: normally set via a URL argument, a language question, or the inline language list. This stores the interview-wide language choice.
92
+
*`session_local.al_user_language`: an optional browser-session override used by the navigation dropdown. If it is set, the interview will use this value before falling back to `al_user_language`.
93
+
94
+
## Session-local and interview-wide language choices
95
+
96
+
Assembly Line now supports two layers of language selection:
97
+
98
+
1.`al_user_language` is the interview-wide language. Use it when you want the primary user's language choice to remain the default for the interview, such as from a landing page, an early language question, or the inline `get_language_list()` helper.
99
+
1.`session_local.al_user_language` is a per-session override. The navigation dropdown uses it so one browser session can switch languages without changing the language another user sees in the same interview.
100
+
101
+
This is especially useful in multi-user interviews. For example, one signer can keep the interview in Spanish while an advocate or a second signer views the same interview in English.
92
102
93
103
## Make the translation file available in your interview
94
104
@@ -119,14 +129,18 @@ When `al_interview_languages` is defined (which is the default) and has at least
119
129
the Assembly Line will add a drop-down menu item in the top right that allows the user
120
130
to switch languages at any time.
121
131
132
+
The drop-down menu now changes language only for the current browser session by setting
133
+
`session_local.al_user_language`. This makes it a good fit for live help, advocate review,
134
+
and multi-user interviews where different people may need different languages at the same time.
135
+
122
136
You can customize this drop-down menu with a block like this:
123
137
124
138
```yaml
125
139
---
126
140
default screen parts:
127
141
navigation bar html: |
128
142
% if enable_al_language and len(al_interview_languages) > 1:
Assembly Line now uses two language-switching events:
212
231
213
-
When the event is triggered, it:
232
+
1. `al_change_language` is used by `get_language_list_dropdown()`. It stores the selected language in `session_local.al_user_language`, so the change only affects the current browser session.
233
+
1. `al_get_language_list_change_language` is used by `get_language_list()`. It updates `al_user_language`, so the change becomes the interview-wide language choice.
214
234
215
-
1. Reads the `lang` parameter from the action arguments
216
-
2. Sets `al_user_language` to the selected language code
217
-
3. Calls Docassemble's `set_language()` function to apply the language change
235
+
On each request, the built-in `initial: True` block checks for `session_local.attr("al_user_language")`
236
+
first. If that value exists, Assembly Line applies it. Otherwise it falls back to `al_user_language`.
218
237
219
-
You normally don't need to handle this event directly, as it's managed automatically
220
-
by the language switching functions. However, if you want to add custom behavior
221
-
when languages are switched, you can define additional logic after the language
222
-
change:
238
+
You normally do not need to define either event yourself, but this is the current built-in logic:
0 commit comments