diff --git a/app/MindWork AI Studio/Tools/CommonTools.cs b/app/MindWork AI Studio/Tools/CommonTools.cs
index 26150880..fd3542b5 100644
--- a/app/MindWork AI Studio/Tools/CommonTools.cs
+++ b/app/MindWork AI Studio/Tools/CommonTools.cs
@@ -1,3 +1,4 @@
+using System.Globalization;
using System.Text;
namespace AIStudio.Tools;
@@ -19,4 +20,32 @@ public static class CommonTools
return sb.ToString();
}
-}
\ No newline at end of file
+
+ ///
+ /// Resolves a from the active language plugin's IETF tag.
+ ///
+ /// The IETF language tag provided by the active language plugin.
+ /// The matching culture when the tag is valid; otherwise .
+ public static CultureInfo DeriveActiveCultureOrInvariant(string? ietfTag)
+ {
+ if (string.IsNullOrWhiteSpace(ietfTag))
+ return CultureInfo.InvariantCulture;
+
+ try
+ {
+ return CultureInfo.GetCultureInfo(ietfTag);
+ }
+ catch (CultureNotFoundException)
+ {
+ return CultureInfo.InvariantCulture;
+ }
+ }
+
+ ///
+ /// Formats a timestamp using the short date and time pattern of the specified culture.
+ ///
+ /// The timestamp to format.
+ /// The culture whose short date and time pattern should be used.
+ /// The localized timestamp string.
+ public static string FormatTimestampToGeneral(DateTime timestamp, CultureInfo culture) => timestamp.ToString("g", culture);
+}