Skip to content

Commit 76c1bf8

Browse files
committed
Move common parameter definitions into Fluent
1 parent a18a7df commit 76c1bf8

File tree

3 files changed

+22
-34
lines changed

3 files changed

+22
-34
lines changed

bot/src/ghutils/cogs/app_commands/github.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
UserGitHubTokens,
2727
UserLogin,
2828
)
29-
from ghutils.utils import l10n
3029
from ghutils.utils.discord.embeds import set_embed_author
3130
from ghutils.utils.discord.references import (
3231
CommitReference,
@@ -56,7 +55,6 @@ class GitHubCog(GHUtilsCog, GroupCog, group_name="gh"):
5655

5756
@app_commands.command()
5857
@app_commands.rename(reference="issue")
59-
@l10n.describe_common("visibility")
6058
async def issue(
6159
self,
6260
interaction: Interaction,
@@ -71,7 +69,6 @@ async def issue(
7169

7270
@app_commands.command()
7371
@app_commands.rename(reference="pr")
74-
@l10n.describe_common("visibility")
7572
async def pr(
7673
self,
7774
interaction: Interaction,
@@ -86,7 +83,6 @@ async def pr(
8683

8784
@app_commands.command()
8885
@app_commands.rename(reference="commit")
89-
@l10n.describe_common("visibility")
9086
async def commit(
9187
self,
9288
interaction: Interaction,
@@ -127,7 +123,6 @@ async def commit(
127123
await respond_with_visibility(interaction, visibility, embed=embed)
128124

129125
@app_commands.command()
130-
@l10n.describe_common("visibility")
131126
async def repo(
132127
self,
133128
interaction: Interaction,
@@ -162,7 +157,6 @@ async def repo(
162157
await respond_with_visibility(interaction, visibility, embed=embed)
163158

164159
@app_commands.command()
165-
@l10n.describe_common("visibility")
166160
async def user(
167161
self,
168162
interaction: Interaction,
@@ -252,7 +246,6 @@ async def logout(self, interaction: Interaction):
252246
)
253247

254248
@app_commands.command()
255-
@l10n.describe_common("visibility")
256249
async def status(
257250
self,
258251
interaction: Interaction,
@@ -311,7 +304,6 @@ async def status(
311304

312305
class Search(SubGroup):
313306
@app_commands.command()
314-
@l10n.describe_common("visibility")
315307
async def files(
316308
self,
317309
interaction: Interaction,

bot/src/ghutils/resources/l10n/en-US/main.ftl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# common parameters
88

9-
parameter-description_common_visibility =
9+
-parameter-description_visibility =
1010
Whether the message should be visible to everyone, or just you.
1111
1212
# /gh issue
@@ -17,6 +17,9 @@ command-description_gh-issue =
1717
parameter-description_gh-issue_reference =
1818
Issue to look up (`owner/repo#123` or `#123`). Use `/gh login` to get autocomplete.
1919
20+
parameter-description_gh-issue_visibility =
21+
{-parameter-description_visibility}
22+
2023
# /gh pr
2124

2225
command-description_gh-pr =
@@ -25,6 +28,9 @@ command-description_gh-pr =
2528
parameter-description_gh-pr_reference =
2629
Pull request to look up (`owner/repo#123` or `#123`). Use `/gh login` to get autocomplete.
2730
31+
parameter-description_gh-pr_visibility =
32+
{-parameter-description_visibility}
33+
2834
# /gh commit
2935

3036
command-description_gh-commit =
@@ -33,16 +39,25 @@ command-description_gh-commit =
3339
parameter-description_gh-commit_reference =
3440
Commit SHA to look up (`owner/repo@sha` or `@sha`). Use `/gh login` to get autocomplete.
3541
42+
parameter-description_gh-commit_visibility =
43+
{-parameter-description_visibility}
44+
3645
# /gh repo
3746

3847
command-description_gh-repo =
3948
Get a link to a GitHub repository.
4049
50+
parameter-description_gh-repo_visibility =
51+
{-parameter-description_visibility}
52+
4153
# /gh user
4254

4355
command-description_gh-user =
4456
Get a link to a GitHub user.
4557
58+
parameter-description_gh-user_visibility =
59+
{-parameter-description_visibility}
60+
4661
# /gh login
4762

4863
command-description_gh-login =
@@ -58,6 +73,9 @@ command-description_gh-logout =
5873
command-description_gh-status =
5974
Show information about GitHub Utils.
6075
76+
parameter-description_gh-status_visibility =
77+
{-parameter-description_visibility}
78+
6179
# /gh search
6280

6381
command-description_gh-search =
@@ -82,3 +100,6 @@ parameter-description_gh-search-files_exact =
82100
83101
parameter-description_gh-search-files_limit =
84102
Maximum number of results to show.
103+
104+
parameter-description_gh-search-files_visibility =
105+
{-parameter-description_visibility}

bot/src/ghutils/utils/l10n.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
"""Localization helpers."""
22

33
import re
4-
from typing import Mapping
54

6-
from discord import app_commands
75
from discord.app_commands import locale_str
86

97
type StrIterable = list[str] | tuple[str, ...]
@@ -30,28 +28,5 @@ def parameter_description(command: str | None, parameter: str):
3028
return locale_str("...", id=parameter_description_id(command, parameter))
3129

3230

33-
def describe_common(*parameters: str):
34-
return describe(common=parameters)
35-
36-
37-
def describe(
38-
dict_args: Mapping[str, StrIterable] | None = None,
39-
**kwargs: StrIterable,
40-
):
41-
"""Localize app command parameters.
42-
43-
Key: command to localize parameters for.
44-
45-
Value: parameter names.
46-
"""
47-
if dict_args:
48-
kwargs |= dict_args
49-
return app_commands.describe(**{
50-
parameter: parameter_description(command, parameter)
51-
for command, parameters in kwargs.items()
52-
for parameter in parameters
53-
})
54-
55-
5631
def _format_identifier(command: str):
5732
return _SEPARATOR_PATTERN.sub("-", command).replace("/", "")

0 commit comments

Comments
 (0)