Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilePopupMenu: pluralize selected files #2466

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

slook
Copy link
Member

@slook slook commented Mar 28, 2023

  • Added: "1 File Selected" or "n Files Selected" translatable strings for the file popup menus
  • Removed: "n File(s) Selected" translatable string

The idea of including the numeric digit within singular version of the string is to help the translators. It also allows flexibility if a number is not desired, such as "No Files" or just the word "Folder" without a number, for example.

image

image

@slook slook changed the title popupmenu selected files human count and size popupmenu pluralize selected files human count Mar 28, 2023
@slook slook changed the title popupmenu pluralize selected files human count FilePopupMenu: pluralize selected files human count Mar 28, 2023
@slook slook force-pushed the popupmenu-selected-files-pluralize branch from 59f201d to 6e62424 Compare March 29, 2023 09:59
@slook slook changed the title FilePopupMenu: pluralize selected files human count FilePopupMenu: pluralize selected files Mar 29, 2023
@mathiascode
Copy link
Member

Apparently gettext.install() can also make ngettext() available, so you can gettext.install(names=["ngettext"]) in i18n.py, then do something like:

        self.items["selected_files"].set_label(
            ngettext("{num} File Selected", "{num} Files Selected", num_files).format(num=num_files)
        )

@slook
Copy link
Member Author

slook commented Jun 2, 2023

It would be nicer to wrap the suggested ngettext() implementation into a function which only requires the key (e.g. "selected_files") to look-up the assigned strings. Otherwise it will be too cumbersome to use when defining menu items and labels etc.

This would also give the intended advantage of having strings defined in the core to be used also in headless mode.

@mathiascode
Copy link
Member

mathiascode commented Jun 2, 2023

It depends. Ideally we would only use a string once in the codebase anyway. We could probably start by defining these strings in popupmenu.py only, and move them somewhere else if they're needed elsewhere in the future.

@mathiascode mathiascode marked this pull request as draft August 8, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants