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

Job title localization #32338

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Content.Server/Access/Systems/AgentIDCardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void AfterUIOpen(EntityUid uid, AgentIDCardComponent component, AfterAct
if (!TryComp<IdCardComponent>(uid, out var idCard))
return;

var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", idCard.JobIcon);
var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.LocalizedJobTitle ?? "", idCard.JobIcon);
_uiSystem.SetUiState(uid, AgentIDCardUiKey.Key, state);
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Access/Systems/IdCardConsoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void UpdateUserInterface(EntityUid uid, IdCardConsoleComponent component
PrivilegedIdIsAuthorized(uid, component),
true,
targetIdComponent.FullName,
targetIdComponent.JobTitle,
targetIdComponent.LocalizedJobTitle,
targetAccessComponent.Tags.ToList(),
possibleAccess,
jobProto,
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/IdentityManagement/IdentitySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private IdentityRepresentation GetIdentityRepresentation(EntityUid target,
if (_idCard.TryFindIdCard(target, out var id))
{
presumedName = string.IsNullOrWhiteSpace(id.Comp.FullName) ? null : id.Comp.FullName;
presumedJob = id.Comp.JobTitle?.ToLowerInvariant();
presumedJob = id.Comp.LocalizedJobTitle?.ToLowerInvariant();
}

// If it didn't find a job, that's fine.
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Medical/SuitSensors/SuitSensorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ public void SetSensor(Entity<SuitSensorComponent> sensors, SuitSensorMode mode,
{
if (card.Comp.FullName != null)
userName = card.Comp.FullName;
if (card.Comp.JobTitle != null)
userJob = card.Comp.JobTitle;
if (card.Comp.LocalizedJobTitle != null)
userJob = card.Comp.LocalizedJobTitle;
userJobIcon = card.Comp.JobIcon;

foreach (var department in card.Comp.JobDepartments)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/PDA/PdaSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null)
{
ActualOwnerName = pda.OwnerName,
IdOwner = id?.FullName,
JobTitle = id?.JobTitle,
JobTitle = id?.LocalizedJobTitle,
StationAlertLevel = pda.StationAlertLevel,
StationAlertColor = pda.StationAlertColor
},
Expand Down
7 changes: 6 additions & 1 deletion Content.Shared/Access/Components/IdCardComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ public sealed partial class IdCardComponent : Component
[DataField]
[AutoNetworkedField]
[Access(typeof(SharedIdCardSystem), typeof(SharedPdaSystem), typeof(SharedAgentIdCardSystem), Other = AccessPermissions.ReadWrite)]
public string? JobTitle;
public LocId? JobTitle;

private string? _jobTitle;

[Access(typeof(SharedIdCardSystem), typeof(SharedPdaSystem), typeof(SharedAgentIdCardSystem), Other = AccessPermissions.ReadWriteExecute)]
public string? LocalizedJobTitle { set => _jobTitle = value; get => _jobTitle ?? Loc.GetString(JobTitle ?? string.Empty); }

/// <summary>
/// The state of the job icon rsi.
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Access/Systems/IdExaminableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public string GetMessage(EntityUid uid)

private string GetNameAndJob(IdCardComponent id)
{
var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})";
var jobSuffix = string.IsNullOrWhiteSpace(id.LocalizedJobTitle) ? string.Empty : $" ({id.LocalizedJobTitle})";

var val = string.IsNullOrWhiteSpace(id.FullName)
? Loc.GetString(id.NameLocId,
Expand Down
9 changes: 5 additions & 4 deletions Content.Shared/Access/Systems/SharedIdCardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public bool TryGetIdCard(EntityUid uid, out Entity<IdCardComponent> idCard)
/// </summary>
/// <remarks>
/// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs.
/// Actually works with the LocalizedJobTitle DataField and not with JobTitle.
/// </remarks>
public bool TryChangeJobTitle(EntityUid uid, string? jobTitle, IdCardComponent? id = null, EntityUid? player = null)
{
Expand All @@ -134,9 +135,9 @@ public bool TryChangeJobTitle(EntityUid uid, string? jobTitle, IdCardComponent?
jobTitle = null;
}

if (id.JobTitle == jobTitle)
if (id.LocalizedJobTitle == jobTitle)
return true;
id.JobTitle = jobTitle;
id.LocalizedJobTitle = jobTitle;
Dirty(uid, id);
UpdateEntityName(uid, id);

Expand Down Expand Up @@ -238,7 +239,7 @@ private void UpdateEntityName(EntityUid uid, IdCardComponent? id = null)
if (!Resolve(uid, ref id))
return;

var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})";
var jobSuffix = string.IsNullOrWhiteSpace(id.LocalizedJobTitle) ? string.Empty : $" ({id.LocalizedJobTitle})";

var val = string.IsNullOrWhiteSpace(id.FullName)
? Loc.GetString(id.NameLocId,
Expand All @@ -251,7 +252,7 @@ private void UpdateEntityName(EntityUid uid, IdCardComponent? id = null)

private static string ExtractFullTitle(IdCardComponent idCardComponent)
{
return $"{idCardComponent.FullName} ({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(idCardComponent.JobTitle ?? string.Empty)})"
return $"{idCardComponent.FullName} ({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(idCardComponent.LocalizedJobTitle ?? string.Empty)})"
.Trim();
}
}
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/job/job-names.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ job-name-unknown = Unknown
job-name-virologist = Virologist
job-name-zombie = Zombie

# Job titles
job-title-visitor = Visitor
job-title-cluwne = Cluwne
job-title-universal = Universal

# Role timers - Make these alphabetical or I cut you
JobAtmosphericTechnician = Atmospheric Technician
JobBartender = Bartender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
- state: default
- state: idvisitor
- type: IdCard
jobTitle: Visitor
jobTitle: job-title-visitor
jobIcon: JobIconVisitor
- type: PresetIdCard
job: Visitor
Expand Down Expand Up @@ -741,7 +741,7 @@
- state: default
- state: idcluwne
- type: IdCard
jobTitle: Cluwne
jobTitle: job-title-cluwne
- type: Unremoveable

- type: entity
Expand Down Expand Up @@ -801,7 +801,7 @@
- type: Item
heldPrefix: green
- type: IdCard
jobTitle: Universal
jobTitle: job-title-universal
jobIcon: JobIconAdmin
- type: Access
groups:
Expand Down
Loading