Skip to content

Allow translating argparse error messages #83645

Closed

Description

@DjMorgul
mannequin
BPO 39464
Nosy @rhettinger, @shihai1991, @DjMorgul, @iritkatriel
PRs
  • bpo-39464: Allow translating argument error messages  #17169
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2020-01-27.13:55:37.792>
    labels = ['type-feature', 'library', '3.9', '3.10', '3.11']
    title = 'Allow translating argparse error messages'
    updated_at = <Date 2021-12-14.16:22:47.266>
    user = 'https://github.com/DjMorgul'

    bugs.python.org fields:

    activity = <Date 2021-12-14.16:22:47.266>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-01-27.13:55:37.792>
    creator = 'DjMorgul'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39464
    keywords = []
    message_count = 4.0
    messages = ['360764', '361156', '361157', '408545']
    nosy_count = 5.0
    nosy_names = ['rhettinger', 'paul.j3', 'shihai1991', 'DjMorgul', 'iritkatriel']
    pr_nums = ['17169']
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue39464'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. DjMorgul commented on Jan 27, 2020

      DjMorgulmannequin
      MannequinAuthor

      Argument error messages display the untranslatable text 'argument ', which should be translatable to other languages, just like it's possible to do with the rest of the constructed error message.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Jan 27, 2020
    3. changed the title [-]Allow translating argument error messages[/-] [+]Allow translating argparse error messages[/+] on Jan 27, 2020
    4. changed the title [-]Allow translating argument error messages[/-] [+]Allow translating argparse error messages[/+] on Jan 27, 2020
    5. shihai1991 commented on Feb 1, 2020

      @shihai1991
      Member

      Paste José's comment from PR17169:

      This message isn't used (only?) in exceptions... it's a message that is given to the console, to notify the user when she didn't provide correct parameters. For example:

      $ python3 ./drt.py -l
      Uso: ./drt.py [-h] [-l LONG_MIN] [-L LONG_MAX] [-v] [-V]
                     entrada.json [salida.tok]
      ./drt.py: error: argument -l/--min-length: se esperaba un parámetro
      

      These are console messages localized into Spanish. The "error:" part is translatable, but it's the same word in Spanish than in English. The "argument" part is what isn't translatable, and it's taken from this "exception".

      I confirmed that my proposed patch, translating that particular string, allows giving a fully localized console output to the user in Spanish, such as:

      ./drt.py: error: parámetro -l/--min-length: se esperaba un parámetro

    6. shihai1991 commented on Feb 1, 2020

      @shihai1991
      Member

      Users interact with console's output, so translated the output info is fine to me.
      Hi,raymond、paul. What's your opinion?

    7. iritkatriel commented on Dec 14, 2021

      @iritkatriel
      Member

      Closed bpo-26726 as duplicate of this.

    8. transferred this issue fromon Apr 10, 2022
    9. savannahostrowski commented on Sep 23, 2024

      @savannahostrowski
      Member

      This was addressed via #27668 and #17169

    10. moved this from Features to Doc issues in Argparse issueson Sep 23, 2024
    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

      3.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions