]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Job title localization (#32338)
authorchavonadelal <156101927+chavonadelal@users.noreply.github.com>
Wed, 9 Oct 2024 15:05:36 +0000 (18:05 +0300)
committerGitHub <noreply@github.com>
Wed, 9 Oct 2024 15:05:36 +0000 (17:05 +0200)
* Job title localization

* Correcting fields

Content.Server/Access/Systems/AgentIDCardSystem.cs
Content.Server/Access/Systems/IdCardConsoleSystem.cs
Content.Server/IdentityManagement/IdentitySystem.cs
Content.Server/Medical/SuitSensors/SuitSensorSystem.cs
Content.Server/PDA/PdaSystem.cs
Content.Shared/Access/Components/IdCardComponent.cs
Content.Shared/Access/Systems/IdExaminableSystem.cs
Content.Shared/Access/Systems/SharedIdCardSystem.cs
Resources/Locale/en-US/job/job-names.ftl
Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml

index 4de908bc3019a2b6e1c0d4001a1ce03105d52888..a38aefce9354b4ebcc189e80af2f3ff515b1e440 100644 (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);
         }
 
index e02664f2bbdfb979c44beb93ed69a8f6633f098f..a9e5d9a6d3ef2c43ac42306fe2366001860f8ca3 100644 (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,
index e110a42483456a71d285a727cdb89934331fbbcf..ff6901f5a92e107db6248d04ec7ea180c8daa21d 100644 (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.
index b1b87ae981d5617fce8068919490f2db7fd7e284..f56b16432e1723b5e9790e6b040b1b6bfe8a8b10 100644 (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)
index cdcdbc02e5fb28e49b339124ff7737098782dc00..7f17b97d0adc73b56ae08e5a15a7f04ccf9244e3 100644 (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
                 },
index ccd4cccbe7b5a5e1ae74a173c26fdc3dcc27d4c7..e80ced646438bd4f20e4f889bab264a472b48f58 100644 (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.
index 13359adcba2dd72184babea21e693f11d663e412..807ccc6616d4aac88bbe5b1cda6b85d6226714d5 100644 (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,
index 8bdc548e353a8892c907fac554878997fbcf6d75..a5a37eecbd07eaa3a567a8f86ef5558a62b56728 100644 (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();
     }
 }
index 0140adf8a2d7116baf73317436dcad351bfef6b2..5a0b615b47040c40cab94b8b76ff1fe59ddd26cf 100644 (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
index a08afa127e05e4ad114febec375528f8dc064f88..ccb83b6aaa373c543393dbe6b2721b4c92055948 100644 (file)
     - state: default
     - state: idvisitor
   - type: IdCard
-    jobTitle: Visitor
+    jobTitle: job-title-visitor
     jobIcon: JobIconVisitor
   - type: PresetIdCard
     job: Visitor
     - state: default
     - state: idcluwne
   - type: IdCard
-    jobTitle: Cluwne
+    jobTitle: job-title-cluwne
   - type: Unremoveable
 
 - type: entity
   - type: Item
     heldPrefix: green
   - type: IdCard
-    jobTitle: Universal
+    jobTitle: job-title-universal
     jobIcon: JobIconAdmin
   - type: Access
     groups: