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

Glossary: Add context to glossary form and change permission check #11063

Merged
merged 12 commits into from May 15, 2024

Conversation

Xzonn
Copy link
Contributor

@Xzonn Xzonn commented Feb 21, 2024

Proposed changes

Add an input box for context to glossary form in the translation UI (#10969), based on NewMonolingualUnitForm:

weblate/weblate/trans/forms.py

Lines 2375 to 2391 in 8f105d7

class NewMonolingualUnitForm(NewUnitBaseForm):
context = forms.CharField(
label=gettext_lazy("Translation key"),
help_text=gettext_lazy(
"Key used to identify the string in the translation file. "
"File-format specific rules might apply."
),
required=True,
)
source = PluralField(
label=gettext_lazy("Source language text"),
help_text=gettext_lazy(
"You can edit this later, as with any other string in "
"the source language."
),
required=True,
)

I also noticed that there is a significant difference between NewMonolingualUnitForm and NewBilingualSourceUnitForm. Should we unify them?

I also changed the permission check from unit.add to glossary.add. Before this commit, terms can not be directly added to the glossary because of this check:

if not source and template:
return Denied(gettext("Add the string to the source language instead."))

Checklist

  • Lint and unit tests pass locally with my changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added documentation to describe my feature.
  • I have squashed my commits into logic units.
  • I have described the changes in the commit messages.

Other information

Screenshot

image

Copy link
Member

@nijel nijel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it share the code with NewBilingualSourceUnitForm? Duplicating the field description and help texts will lead to them getting out of sync over time.

weblate/glossary/forms.py Outdated Show resolved Hide resolved
@Xzonn
Copy link
Contributor Author

Xzonn commented Feb 21, 2024

I changed TermForm to inherit NewBilingerGlossaryUnitForm in order to avoid the field description and help texts:

Screenshot

image

The font size for .highlighted-output should be set to 16px, but I'm not sure which CSS file to add to.

@Xzonn Xzonn force-pushed the glossary-form branch 2 times, most recently from 770eb1d to 54dd17f Compare February 26, 2024 16:52
Copy link

This pull request has been automatically marked as stale because there wasn’t any recent activity.

It will be closed soon if no further action occurs.

Thank you for your contributions!

@github-actions github-actions bot added the wontfix Nobody will work on this. label Mar 28, 2024
@Xzonn Xzonn requested a review from nijel March 28, 2024 08:29
@github-actions github-actions bot removed the wontfix Nobody will work on this. label Mar 29, 2024
nijel added a commit that referenced this pull request Apr 10, 2024
Otherwise the CSS changes from it are applied to the popup what is not
desired. Discovered in #11063
weblate/static/style-bootstrap.css Outdated Show resolved Hide resolved
weblate/glossary/forms.py Outdated Show resolved Hide resolved
weblate/glossary/forms.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 90.62%. Comparing base (6aee586) to head (994edb7).
Report is 1656 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #11063      +/-   ##
==========================================
- Coverage   90.82%   90.62%   -0.21%     
==========================================
  Files         554      570      +16     
  Lines       57306    58599    +1293     
  Branches     9122     9373     +251     
==========================================
+ Hits        52046    53103    +1057     
- Misses       3640     3810     +170     
- Partials     1620     1686      +66     
Files Coverage Δ
weblate/glossary/tests.py 100.00% <ø> (ø)
weblate/glossary/forms.py 74.13% <81.81%> (-1.58%) ⬇️
weblate/trans/forms.py 87.84% <69.23%> (-0.03%) ⬇️

... and 241 files with indirect coverage changes

@nijel nijel added this to the 5.6 milestone Apr 23, 2024
@nijel nijel linked an issue May 7, 2024 that may be closed by this pull request
@nijel nijel self-assigned this May 7, 2024
@nijel nijel merged commit edff476 into WeblateOrg:main May 15, 2024
30 of 31 checks passed
@nijel
Copy link
Member

nijel commented May 15, 2024

Merged, thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unify the two ways of adding glossary terms
2 participants