Replace configuration strings with translatable strings

This commit is contained in:
FeTetra 2025-02-16 22:41:57 -05:00
commit 3041d2c0fa
3 changed files with 14 additions and 21 deletions

View file

@ -93,4 +93,13 @@
<data name="read_only_warn" xml:space="preserve"> <data name="read_only_warn" xml:space="preserve">
<value>This instance is currently in read-only mode. Level and photo uploads, comments, reviews, and certain profile changes will be restricted until read-only mode is disabled.</value> <value>This instance is currently in read-only mode. Level and photo uploads, comments, reviews, and certain profile changes will be restricted until read-only mode is disabled.</value>
</data> </data>
<data name="email_enforcement_message_main" xml:space="preserve">
<value>This instance has email enforcement enabled. If you haven't already, you will need to set and verify an email address to use most features.</value>
</data>
<data name="email_enforcement_message_no_email" xml:space="preserve">
<value>You do not have an email set on your account. You can set an email by opening the text chat and typing "/setemail [youremail@example.com]" (do not include the brackets.)</value>
</data>
<data name="email_enforcement_message_verify_email" xml:space="preserve">
<value>You have set an email address on your account, but you have not verified it. Make sure to check your inbox for a verification email. If you have not recieved an email, please contact an instance administrator for further assistance.</value>
</data>
</root> </root>

View file

@ -57,7 +57,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
UserEntity? user = await this.database.UserFromGameToken(token); UserEntity? user = await this.database.UserFromGameToken(token);
StringBuilder announceText = new(ServerConfiguration.Instance.AnnounceText); StringBuilder announceText = new(ServerConfiguration.Instance.AnnounceText + "\n\n");
announceText.Replace("%user", user.Username); announceText.Replace("%user", user.Username);
announceText.Replace("%id", token.UserId.ToString()); announceText.Replace("%id", token.UserId.ToString());
@ -69,15 +69,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
if (EmailEnforcementConfiguration.Instance.EnableEmailEnforcement) if (EmailEnforcementConfiguration.Instance.EnableEmailEnforcement)
{ {
announceText.Append(EmailEnforcementConfiguration.Instance.EmailEnforcementMessageMain + "\n\n"); announceText.Append(BaseLayoutStrings.EmailEnforcementWarnMain.Translate(LocalizationManager.DefaultLang) + "\n\n");
if (user.EmailAddress == null) if (user.EmailAddress == null)
{ {
announceText.Append(EmailEnforcementConfiguration.Instance.EmailEnforcementMessageNoEmail + "\n\n"); announceText.Append(BaseLayoutStrings.EmailEnforcementWarnNoEmail.Translate(LocalizationManager.DefaultLang) + "\n\n");
} }
else if (!user.EmailAddressVerified) else if (!user.EmailAddressVerified)
{ {
announceText.Append(EmailEnforcementConfiguration.Instance.EmailEnforcementMessageVerify + "\n\n"); announceText.Append(BaseLayoutStrings.EmailEnforcementWarnVerifyEmail.Translate(LocalizationManager.DefaultLang) + "\n\n");
} }
} }

View file

@ -7,7 +7,7 @@ namespace LBPUnion.ProjectLighthouse.Configuration;
public class EmailEnforcementConfiguration : ConfigurationBase<EmailEnforcementConfiguration> public class EmailEnforcementConfiguration : ConfigurationBase<EmailEnforcementConfiguration>
{ {
public override int ConfigVersion { get; set; } = 3; public override int ConfigVersion { get; set; } = 4;
public override string ConfigName { get; set; } = "enforce-email.yml"; public override string ConfigName { get; set; } = "enforce-email.yml";
@ -67,22 +67,6 @@ public class EmailEnforcementConfiguration : ConfigurationBase<EmailEnforcementC
"update_my_pins", "update_my_pins",
}; };
public string EmailEnforcementMessageMain { get; set; } =
"This lighthouse instance has email enforcement enabled. " +
"If you haven't already, you will need to set and verify " +
"an email address to use most features. ";
public string EmailEnforcementMessageNoEmail { get; set; } =
"You do not have an email set on your account. You can set " +
"an email by opening the text chat and typing \"/setemail " +
"[youremail@example.com]\" (do not include the brackets.) ";
public string EmailEnforcementMessageVerify { get; set; } =
"You have set an email address on your account, but you have not " +
"verified it. Make sure to check your inbox for a verification email. " +
"If you have not received an email, please contact an instance " +
"administrator for further assistance. ";
public override ConfigurationBase<EmailEnforcementConfiguration> Deserialize public override ConfigurationBase<EmailEnforcementConfiguration> Deserialize
(IDeserializer deserializer, string text) => (IDeserializer deserializer, string text) =>
deserializer.Deserialize<EmailEnforcementConfiguration>(text); deserializer.Deserialize<EmailEnforcementConfiguration>(text);