|
@@ -2,6 +2,8 @@ using System.Diagnostics;
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
using System.Globalization;
|
|
|
using System.Reflection;
|
|
|
+using System.Resources;
|
|
|
+using Terminal.Gui.Resources;
|
|
|
|
|
|
namespace Terminal.Gui;
|
|
|
|
|
@@ -63,31 +65,29 @@ public static partial class Application
|
|
|
{
|
|
|
// Return all culture for which satellite folder found with culture code.
|
|
|
return cultures.Where (
|
|
|
- cultureInfo =>
|
|
|
- Directory.Exists (Path.Combine (assemblyLocation, cultureInfo.Name))
|
|
|
- && File.Exists (Path.Combine (assemblyLocation, cultureInfo.Name, resourceFilename))
|
|
|
- )
|
|
|
- .ToList ();
|
|
|
+ cultureInfo =>
|
|
|
+ Directory.Exists (Path.Combine (assemblyLocation, cultureInfo.Name))
|
|
|
+ && File.Exists (Path.Combine (assemblyLocation, cultureInfo.Name, resourceFilename))
|
|
|
+ )
|
|
|
+ .ToList ();
|
|
|
}
|
|
|
|
|
|
- // It's called from a self-contained single.file.
|
|
|
- try
|
|
|
- {
|
|
|
- // <InvariantGlobalization>false</InvariantGlobalization>
|
|
|
- return
|
|
|
- [
|
|
|
- new ("fr-FR"),
|
|
|
- new ("ja-JP"),
|
|
|
- new ("pt-PT"),
|
|
|
- new ("zh-Hans")
|
|
|
- ];
|
|
|
- }
|
|
|
- catch (CultureNotFoundException)
|
|
|
- {
|
|
|
- // <InvariantGlobalization>true</InvariantGlobalization>
|
|
|
- // Only the invariant culture is supported in globalization-invariant mode.
|
|
|
- return [];
|
|
|
- }
|
|
|
+ // It's called from a self-contained single-file and get available cultures from the embedded resources strings.
|
|
|
+ return GetAvailableCulturesFromEmbeddedResources ();
|
|
|
+ }
|
|
|
+
|
|
|
+ internal static List<CultureInfo> GetAvailableCulturesFromEmbeddedResources ()
|
|
|
+ {
|
|
|
+ ResourceManager rm = new (typeof (Strings));
|
|
|
+
|
|
|
+ CultureInfo [] cultures = CultureInfo.GetCultures (CultureTypes.AllCultures);
|
|
|
+
|
|
|
+ return cultures.Where (
|
|
|
+ cultureInfo =>
|
|
|
+ !cultureInfo.Equals (CultureInfo.InvariantCulture)
|
|
|
+ && rm.GetResourceSet (cultureInfo, true, false) is { }
|
|
|
+ )
|
|
|
+ .ToList ();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|