Skip to content

Hint for language-region pair where language is expected #4142

Closed

Description

@laurmaedje

Description

When writing #set text(lang: "en-gb"), we should have a hint that you should use the region field instead.

Use Case

Helps people fix the problem.

Activity

  1. added
    feature request
    good first issue
    diagnostics
    on May 16, 2024
  2. Coekjan commented on May 16, 2024

    @Coekjan
    Contributor

    Hi, I wonder if this diagnostics shall be implemented in Lang::from_str. I see current diagnostics information "expected two or three letter language code (ISO 639-1/2/3)" comes from there.

  3. laurmaedje commented on May 16, 2024

    @laurmaedje
    MemberAuthor

    Unfortunately, the casting infrastructure doesn't support hints yet (FromValue always returns a StrResult). So, I think the only place we can do this at the moment is by augmenting the text.lang with a #[parse] annotation (you can search the codebase to see how it works).

  4. Coekjan commented on May 18, 2024

    @Coekjan
    Contributor

    I am thinking about when to hint something like "you should use region field". Here are some options I thought out:
    Op1: The arg contains -
    Op2: Op1 + the length of arg.split('-') is 2
    Op3: Op2 + arg[0] can be parsed into Lang & arg[1] can be parsed into Region

    Or does anyone have some other ideas?

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

    diagnosticsfeature requestgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions