-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Attempt to fix all unlocalized lines (part 2: cmd) #40752
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
base: master
Are you sure you want to change the base?
Conversation
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Holy moth |
Is it possible to split this into multiple PRs? Or is the large diff unavoidable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I be doing a naughty naughty and looking at this while Im at work so this is all Ive got to so far
|
||
public override string Command => "showsubfloor"; | ||
|
||
public override string Help => Loc.GetString($"cmd-{Command}-help", ("command", Command)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line and description aren't necessary in localized commands as they're fetched automatically by the parent class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocalizedCommand which is inherited by LocalizedEntityCommand does have it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the linked PR and the associated commands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it better this way. It could be useful for renaming the command. We need a third person to decide. D:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have had a moment of enlightenment that has foretold your reasoning behind this and I've come to agree.
I then bring 2 questions:
What does Loc.GetString do if a format value is passed but the string its formatting doesn't contain the formatee.
And if it silently ignores it, can we just update the help line in the parent class to get the name, as you've suggested above. This would let us keep these help overrides cleaned up.
Was also thinking that usage string with the command name could have its own locale string that could be used by this. Maybe I'm being too ambitious. I will dig deeper this weekend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think everything will be fine. I'll do the PR in RobustToolbox a little later. I don't know about localizing the commands, but I think can do it in another PR if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what i can see in fluent source code it looks pretty close to the fact that it should ignore arguments passed if they are not used. It cretes Scope from arguments and then asks to resolve arguments as it sees them in string to be formatted. So it would probably be fine to put additional arguments all the time? At the same time, when you put no arguments, it does not create bunch of objects, so it gives less memory workload. Meh. Its not like command helper props are on hot path :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works out great then. Shouldn't be an issue regardless as this updates most if not all help strings to take the command name as an argument and any future command additions should follow suit.
_overlay.AddOverlay(new AccessOverlay(EntityManager, _cache, _xform)); | ||
|
||
shell.WriteLine(Loc.GetString($"cmd-showaccessreaders-status", ("status", !existing))); | ||
shell.WriteLine(Loc.GetString($"cmd-{Command}-status", ("status", !existing))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of doing this as I believe it hurts readability in the commands and I've been removing this in my own localization prs. Pinging @slarticodefast since he's reviewed most of mine to see if he has an opinion on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the style from this PR #22897.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid doing this, in case we rename the command in the future it would break all ftl string names and we would have to rename all of them.
It's not impossible, but it will be difficult. It was easier for me to fix all .flt files to one format, after all the commands, without thinking about which commands with .flt will be in this PR. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
||
public override string Command => "showaccessreaders"; | ||
|
||
public override string Help => Loc.GetString($"cmd-{Command}-help", ("command", Command)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was being done to dynamically pass the command name as an argument to the usage. I was a bit off put by it but maybe its worth considering? Would help for example if the command name is changed to something russian in a fork.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then do that in the parent instead of overriding it manually in every single command.
_overlay.AddOverlay(new AccessOverlay(EntityManager, _cache, _xform)); | ||
|
||
shell.WriteLine(Loc.GetString($"cmd-showaccessreaders-status", ("status", !existing))); | ||
shell.WriteLine(Loc.GetString($"cmd-{Command}-status", ("status", !existing))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid doing this, in case we rename the command in the future it would break all ftl string names and we would have to rename all of them.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@slarticodefast @Pok27 Engine change was merged. I assume there needs to be an engine update for this now yes? |
{ | ||
if (args.Length != 2) | ||
{ | ||
shell.WriteError(Loc.GetString(Loc.GetString("cmd-addaction-invalid-args"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this happened twice. Not a lot, just weird its happened twice.
Yeah |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This nearly killed me. I'm still dizzy.
Overall I think its pretty good.
I've suggested some cleanup that should be done as part of converting comands to LocalizedEntityCommands. Namely removing the IEntityManager dependency and replace any usages of it with EntityManager (as its inherited from the parent class).
I've also gone ahead and suggested that you use generics from shell.ftl where possible. I intentionally didn't make this suggestion if the command was already using its own localized variant.
I believe I also made a few comments drawing attention to some strings that can have generics made for them as they're used a few times throughout, but that can be saved for a later date.
Cheers to command localizing 🥂
if (args.Length < 4) | ||
{ | ||
shell.WriteLine($"Not enough arguments.\n{Help}"); | ||
shell.WriteLine(Loc.GetString("cmd-addreagent-not-enough-args")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer the generic shell loc string be used here, but given that this PR is already big enough, that can probably be saved for a future cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally some of these can be converted to LEC but that can also be saved.
if (shell.Player?.AttachedEntity is not { } entity) | ||
{ | ||
shell.WriteError("This command can only be ran by a player with an attached entity."); | ||
shell.WriteError(Loc.GetString("cmd-adminlogbulk-player-only")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this one to shell-must-be-attached-to-entity
if (args.Length < 3) | ||
{ | ||
shell.WriteLine(Loc.GetString("osay-command-error-args")); | ||
shell.WriteLine(Loc.GetString("cmd-osay-error-args")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can use the generic shell-wrong-arguments-number-needs-specific or shell-wrong-arguments-number
shell.WriteLine(Loc.GetString(toggle.Value | ||
? "panicbunker-command-disable-with-admins-enabled" | ||
: "panicbunker-command-disable-with-admins-disabled" | ||
? "cmd-panicbunker_disable_with_admins-enabled" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a reason to change these line titles like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Command key renamed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right right, but why the underscore? convention would use hyphen.
cmd-panicbunker-disable-with-admins-enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The structure cmd-(commandName)-(text)
seems to be more important
if (args.Length != 1 && args.Length != 2) | ||
{ | ||
shell.WriteLine($"Invalid amount of args. {Help}"); | ||
shell.WriteLine(Loc.GetString("cmd-rolebanlist-invalid-args", ("help", Help))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be converted to a generic too, but that can be saved for later.
public sealed class StatValuesCommand : LocalizedEntityCommands | ||
{ | ||
[Dependency] private readonly EuiManager _eui = default!; | ||
[Dependency] private readonly IEntityManager _entManager = default!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chuu Chuu
Same here. Make sure to replace _entManager with EntityManager below too.
public sealed class InvokeVerbCommand : IConsoleCommand | ||
public sealed class InvokeVerbCommand : LocalizedEntityCommands | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this dependency. Replace _entManager with EntityManager below.
public sealed class ListVerbsCommand : IConsoleCommand | ||
public sealed class ListVerbsCommand : LocalizedEntityCommands | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this dependency. Replace _entManager with EntityManager below.
public sealed class ListVerbsCommand : IConsoleCommand | ||
public sealed class ListVerbsCommand : LocalizedEntityCommands | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this dependency. Replace _entManager with EntityManager below.
|
||
if (!await _dbManager.GetWhitelistStatusAsync(session.UserId)) | ||
_netManager.DisconnectChannel(session.Channel, Loc.GetString("whitelist-not-whitelisted")); | ||
_netManager.DisconnectChannel(session.Channel, Loc.GetString("whitelist-not-whitelisted")); // TODO: No localization key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest going ahead and resolving this as appose to adding a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to figure out what this is, where to create the key, and what to write there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Righty O
Thanks for the review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're bringing tears of joy to my eyes. This looks great. I forgot to clarify that entity systems can just be brought in as dependencies for LEC commands but other than that the code looks good.
Also really appreciate the cleanup, especially to the dozens of $ strings I dotted around because I didn't realize those were just C# format strings 😅
A maintainer still needs to give it the ole slice and dice but I reckon you're pretty much there.
var mapsSystem = _entManager.System<SharedMapSystem>(); | ||
var tileSystem = _entManager.System<TileSystem>(); | ||
var turfSystem = _entManager.System<TurfSystem>(); | ||
var mapsSystem = EntityManager.System<SharedMapSystem>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:despair:
I should've clarified in my initial review, I'm sorry ;(
These can be made dependencies in LEC commands.
} | ||
|
||
var atmos = _entities.EntitySysManager.GetEntitySystem<AtmosphereSystem>(); | ||
var atmos = EntityManager.EntitySysManager.GetEntitySystem<AtmosphereSystem>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. This is just an even more convoluted way to get the AtmosphereSystem dependency.
Content.Server/Maps/PlanetCommand.cs
Outdated
} | ||
|
||
var biomeSystem = _entManager.System<BiomeSystem>(); | ||
var biomeSystem = EntityManager.System<BiomeSystem>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dependency goblin strikes again 😈
IConsoleCommand
dead, now onlyLocalizedEntityCommands
/LocalizedCommands
I looked through all command files and their localization keys and fixed/added the missing ones
Required space-wizards/RobustToolbox#6248