Job title localization (#32338)

* Job title localization

* Correcting fields
This commit is contained in:
chavonadelal
2024-10-09 18:05:36 +03:00
committed by GitHub
parent fc1c709d44
commit 6d99597349
10 changed files with 26 additions and 15 deletions

View File

@@ -67,7 +67,7 @@ namespace Content.Server.Access.Systems
if (!TryComp<IdCardComponent>(uid, out var idCard)) if (!TryComp<IdCardComponent>(uid, out var idCard))
return; 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); _uiSystem.SetUiState(uid, AgentIDCardUiKey.Key, state);
} }

View File

@@ -96,7 +96,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
PrivilegedIdIsAuthorized(uid, component), PrivilegedIdIsAuthorized(uid, component),
true, true,
targetIdComponent.FullName, targetIdComponent.FullName,
targetIdComponent.JobTitle, targetIdComponent.LocalizedJobTitle,
targetAccessComponent.Tags.ToList(), targetAccessComponent.Tags.ToList(),
possibleAccess, possibleAccess,
jobProto, jobProto,

View File

@@ -166,7 +166,7 @@ public sealed class IdentitySystem : SharedIdentitySystem
if (_idCard.TryFindIdCard(target, out var id)) if (_idCard.TryFindIdCard(target, out var id))
{ {
presumedName = string.IsNullOrWhiteSpace(id.Comp.FullName) ? null : id.Comp.FullName; 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. // If it didn't find a job, that's fine.

View File

@@ -363,8 +363,8 @@ public sealed class SuitSensorSystem : EntitySystem
{ {
if (card.Comp.FullName != null) if (card.Comp.FullName != null)
userName = card.Comp.FullName; userName = card.Comp.FullName;
if (card.Comp.JobTitle != null) if (card.Comp.LocalizedJobTitle != null)
userJob = card.Comp.JobTitle; userJob = card.Comp.LocalizedJobTitle;
userJobIcon = card.Comp.JobIcon; userJobIcon = card.Comp.JobIcon;
foreach (var department in card.Comp.JobDepartments) foreach (var department in card.Comp.JobDepartments)

View File

@@ -192,7 +192,7 @@ namespace Content.Server.PDA
{ {
ActualOwnerName = pda.OwnerName, ActualOwnerName = pda.OwnerName,
IdOwner = id?.FullName, IdOwner = id?.FullName,
JobTitle = id?.JobTitle, JobTitle = id?.LocalizedJobTitle,
StationAlertLevel = pda.StationAlertLevel, StationAlertLevel = pda.StationAlertLevel,
StationAlertColor = pda.StationAlertColor StationAlertColor = pda.StationAlertColor
}, },

View File

@@ -20,7 +20,12 @@ public sealed partial class IdCardComponent : Component
[DataField] [DataField]
[AutoNetworkedField] [AutoNetworkedField]
[Access(typeof(SharedIdCardSystem), typeof(SharedPdaSystem), typeof(SharedAgentIdCardSystem), Other = AccessPermissions.ReadWrite)] [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> /// <summary>
/// The state of the job icon rsi. /// The state of the job icon rsi.

View File

@@ -67,7 +67,7 @@ public sealed class IdExaminableSystem : EntitySystem
private string GetNameAndJob(IdCardComponent id) 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) var val = string.IsNullOrWhiteSpace(id.FullName)
? Loc.GetString(id.NameLocId, ? Loc.GetString(id.NameLocId,

View File

@@ -116,6 +116,7 @@ public abstract class SharedIdCardSystem : EntitySystem
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs. /// 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> /// </remarks>
public bool TryChangeJobTitle(EntityUid uid, string? jobTitle, IdCardComponent? id = null, EntityUid? player = null) public bool TryChangeJobTitle(EntityUid uid, string? jobTitle, IdCardComponent? id = null, EntityUid? player = null)
{ {
@@ -134,9 +135,9 @@ public abstract class SharedIdCardSystem : EntitySystem
jobTitle = null; jobTitle = null;
} }
if (id.JobTitle == jobTitle) if (id.LocalizedJobTitle == jobTitle)
return true; return true;
id.JobTitle = jobTitle; id.LocalizedJobTitle = jobTitle;
Dirty(uid, id); Dirty(uid, id);
UpdateEntityName(uid, id); UpdateEntityName(uid, id);
@@ -238,7 +239,7 @@ public abstract class SharedIdCardSystem : EntitySystem
if (!Resolve(uid, ref id)) if (!Resolve(uid, ref id))
return; 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) var val = string.IsNullOrWhiteSpace(id.FullName)
? Loc.GetString(id.NameLocId, ? Loc.GetString(id.NameLocId,
@@ -251,7 +252,7 @@ public abstract class SharedIdCardSystem : EntitySystem
private static string ExtractFullTitle(IdCardComponent idCardComponent) 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(); .Trim();
} }
} }

View File

@@ -62,6 +62,11 @@ job-name-unknown = Unknown
job-name-virologist = Virologist job-name-virologist = Virologist
job-name-zombie = Zombie 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 # Role timers - Make these alphabetical or I cut you
JobAtmosphericTechnician = Atmospheric Technician JobAtmosphericTechnician = Atmospheric Technician
JobBartender = Bartender JobBartender = Bartender

View File

@@ -443,7 +443,7 @@
- state: default - state: default
- state: idvisitor - state: idvisitor
- type: IdCard - type: IdCard
jobTitle: Visitor jobTitle: job-title-visitor
jobIcon: JobIconVisitor jobIcon: JobIconVisitor
- type: PresetIdCard - type: PresetIdCard
job: Visitor job: Visitor
@@ -741,7 +741,7 @@
- state: default - state: default
- state: idcluwne - state: idcluwne
- type: IdCard - type: IdCard
jobTitle: Cluwne jobTitle: job-title-cluwne
- type: Unremoveable - type: Unremoveable
- type: entity - type: entity
@@ -801,7 +801,7 @@
- type: Item - type: Item
heldPrefix: green heldPrefix: green
- type: IdCard - type: IdCard
jobTitle: Universal jobTitle: job-title-universal
jobIcon: JobIconAdmin jobIcon: JobIconAdmin
- type: Access - type: Access
groups: groups: