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

Reuse server strings when possible in stats #3442

Merged
merged 5 commits into from
Jan 21, 2025

Conversation

reosarevok
Copy link
Member

Description

We were making people translate stuff twice a lot more than strictly needed, and @mwiencek suggested we don't. I'm sure I've missed some reused strings, but this is most of them.

On top of #3392 because that's where this started and this has strings from there.

@reosarevok reosarevok added the Refactoring Refactoring-only PRs (eslint fixes etc) label Jan 7, 2025
@reosarevok
Copy link
Member Author

We actually have a test ensuring we don't do this, so I'm assuming it is intentional? see https://app.circleci.com/pipelines/github/metabrainz/musicbrainz-server/12638/workflows/b2485960-7220-46b2-9416-38fecdf44aa9/jobs/20969 @yvanzo, can you remind us why?

@mwiencek
Copy link
Member

mwiencek commented Jan 7, 2025

See #3139 and #3141, particularly #3141 (comment).

I think the gist is:

  • Mixing l and l_statistics (and their variants) may imply bugs.
  • Weblate supports translation propagation which should reduce the burden of re-translating things.

I'm not qualified to speak to the second point, though.

@reosarevok
Copy link
Member Author

Ah, ok. Well, I do feel that there's some cases where this makes sense, but I guess if we wanted to do it it could be made more explicit (something like aliasing it to l_server so it only works if explicitly requested?). Then it would still save translators the effort, but it would be less likely to be done accidentally and lead to bugs?

@mwiencek
Copy link
Member

mwiencek commented Jan 7, 2025

Adding an explicit l_server alias for use in files with mixed domains sounds like a good idea. (I see the domain is just named "server" on Weblate, which I didn't know, but still "mb_server" everywhere throughout the code, so l_mb_server seems clearer code-wise?)

@reosarevok reosarevok force-pushed the less-split-statistics branch from a3dd3cc to 71f4c0b Compare January 16, 2025 16:43
We were making people translate stuff twice a lot more than strictly
needed, and mwiencek suggested we don't. I'm sure I've missed some
reused strings, but this is most of them.

To ensure we don't accidentally use l for statistics strings,
this explicitly imports l as lMbServer and uses that.
We have a test to prevent bare l(), but it doesn't seem to work
at the moment since it wasn't triggered by this.
@reosarevok reosarevok force-pushed the less-split-statistics branch from 71f4c0b to 0e9808a Compare January 16, 2025 16:46
 1. The `!` negation does not actually cause the script to exit (despite `set -e`)
    if the `git grep` succeeds (finds matches). See [1]:

    "The shell does not exit if the command that fails is part of the command
     list immediately following a while or until keyword, part of the test in
     an if statement, part of any command executed in a && or || list except
     the command following the final && or ||, any command in a pipeline but
     the last, or if the command’s return status is being inverted with !."

    Thus I've replaced the `!` at the beginning of the command with
    `&& { exit 1; }` at the end.

 2. It appears that the tests could hang on the `git grep` command if it
    produced too many matches due to the results being paged. I've also added
    the `--no-pager` flag to resolve this.

[1] https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html:
@reosarevok
Copy link
Member Author

Did you test the test works when you break some stuff? :) I pushed an extra commit to make eslint allow l_mb_server as we discussed yesterday.

This was blocked by eslint but we have exceptions for all others,
and looks a lot more readable than lMbServer (and related names)
@reosarevok reosarevok force-pushed the less-split-statistics branch from de73f2d to c58644d Compare January 17, 2025 10:58
These aren't used yet, but it seems likely they will be in the future, so it
shouldn't hurt to add them.
@mwiencek
Copy link
Member

Did you test the test works when you break some stuff? :) I pushed an extra commit to make eslint allow l_mb_server as we discussed yesterday.

I had tested it manually by opening a bash shell and running the relevant lines by hand (making sure the shell exited when it found matches, etc.).

@reosarevok reosarevok merged commit 14cf92b into metabrainz:master Jan 21, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring Refactoring-only PRs (eslint fixes etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants