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))
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);
}

View File

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

View File

@@ -166,7 +166,7 @@ public sealed class IdentitySystem : SharedIdentitySystem
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.

View File

@@ -363,8 +363,8 @@ public sealed class SuitSensorSystem : EntitySystem
{
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)

View File

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

View File

@@ -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.

View File

@@ -67,7 +67,7 @@ public sealed class IdExaminableSystem : EntitySystem
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,

View File

@@ -116,6 +116,7 @@ public abstract class SharedIdCardSystem : EntitySystem
/// </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)
{
@@ -134,9 +135,9 @@ public abstract class SharedIdCardSystem : EntitySystem
jobTitle = null;
}
if (id.JobTitle == jobTitle)
if (id.LocalizedJobTitle == jobTitle)
return true;
id.JobTitle = jobTitle;
id.LocalizedJobTitle = jobTitle;
Dirty(uid, id);
UpdateEntityName(uid, id);
@@ -238,7 +239,7 @@ public abstract class SharedIdCardSystem : EntitySystem
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,
@@ -251,7 +252,7 @@ public abstract class SharedIdCardSystem : EntitySystem
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();
}
}

View File

@@ -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

View File

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