Skip to content

Access internal localization from typst document #7536

Open

Description

@TuTiuTe

Description

When setting a document's language, some parts of the document are translated (ie outline).
In particular for package development, it would be nice to be able to access it

Implementation wise, I was thinking of either:

  • exposing a function, like localize(word: str, lang: lang.text | auto | none = auto)
  • exposing a map, like localization, and if you want to access the default outline translation, you'd access with #context localization.outline

The first option is error prone (if the word does not exist) and can be misleading (could hint at user made localization which is not its purpose), while the second option can be rather verbose when working in multilingual contexts (would need to do {set(lang: "fr"); #context localization.outline} to get a different language)

Something to keep in mind is that relying on context for both function would probably wrap the output in a context block, which might be unwanted in some cases

Let me know if I missed an already existing way to do this

Use Case

This feature would be useful for libraries that try to supplement typst in a generic way. I'm looking at Touying for example, that implements its own translations of outline because it wants to set the title of the slide to the title of the outline, and can't work its way backwards to extract the name from the outline body.

Activity

  1. added
    feature request
    on Dec 6, 2025
  2. ortolot commented on Dec 17, 2025

    @ortolot

    I am working on a package to mimic the varioref LaTeX package, and that would be useful to me for implementing things like “figure 3 on the preceding page”.

  3. added
    scripting
    i18n
    on Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requesti18nscripting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions