Skip to content

Commit 2d66415

Browse files
committed
V2026.2.7
1 parent 0b0c0f1 commit 2d66415

4 files changed

Lines changed: 8 additions & 50 deletions

File tree

‎Nickvision.Desktop/Globalization/GettextTranslationService.cs‎

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using GetText;
22
using Nickvision.Desktop.Application;
3-
using Nickvision.Desktop.System;
43
using System;
54
using System.Collections.Generic;
65
using System.Globalization;
@@ -14,7 +13,7 @@ namespace Nickvision.Desktop.Globalization;
1413
/// </summary>
1514
public class GettextTranslationService : ITranslationService
1615
{
17-
private readonly AppInfo _appInfo;
16+
private readonly string _domainName;
1817
private Catalog? _catalog;
1918
private string _language;
2019

@@ -29,19 +28,19 @@ public class GettextTranslationService : ITranslationService
2928
/// </remarks>
3029
public GettextTranslationService(AppInfo appInfo, string language = "")
3130
{
32-
_appInfo = appInfo;
31+
_domainName = appInfo.EnglishShortName.Replace(" ", "").ToLower();
3332
_language = language;
3433
if (string.IsNullOrEmpty(_language))
3534
{
36-
_catalog = new Catalog(_appInfo.EnglishShortName, System.Environment.ExecutingDirectory);
35+
_catalog = new Catalog(_domainName, System.Environment.ExecutingDirectory);
3736
}
3837
else if (_language == "C")
3938
{
4039
_catalog = null;
4140
}
4241
else
4342
{
44-
_catalog = !AvailableLanguages.Contains(_language) ? new Catalog(_appInfo.EnglishShortName, System.Environment.ExecutingDirectory) : _catalog = new Catalog(_appInfo.EnglishShortName, System.Environment.ExecutingDirectory, new CultureInfo(language));
43+
_catalog = !AvailableLanguages.Contains(_language) ? new Catalog(_domainName, System.Environment.ExecutingDirectory) : _catalog = new Catalog(_domainName, System.Environment.ExecutingDirectory, new CultureInfo(language));
4544
}
4645
}
4746

@@ -61,15 +60,15 @@ public string Language
6160
_language = value;
6261
if (string.IsNullOrEmpty(_language))
6362
{
64-
_catalog = new Catalog(_appInfo.EnglishShortName, System.Environment.ExecutingDirectory);
63+
_catalog = new Catalog(_domainName, System.Environment.ExecutingDirectory);
6564
}
6665
else if (_language == "C")
6766
{
6867
_catalog = null;
6968
}
7069
else
7170
{
72-
_catalog = !AvailableLanguages.Contains(_language) ? new Catalog(_appInfo.EnglishShortName, System.Environment.ExecutingDirectory) : _catalog = new Catalog(_appInfo.EnglishShortName, System.Environment.ExecutingDirectory, new CultureInfo(_language));
71+
_catalog = !AvailableLanguages.Contains(_language) ? new Catalog(_domainName, System.Environment.ExecutingDirectory) : _catalog = new Catalog(_domainName, System.Environment.ExecutingDirectory, new CultureInfo(_language));
7372
}
7473
}
7574
}
@@ -84,7 +83,7 @@ public IEnumerable<string> AvailableLanguages
8483
var languages = new List<string>();
8584
foreach (var directory in Directory.EnumerateDirectories(System.Environment.ExecutingDirectory))
8685
{
87-
if (File.Exists(Path.Combine(directory, $"{_appInfo.EnglishShortName}.mo")))
86+
if (File.Exists(Path.Combine(directory, $"{_domainName}.mo")))
8887
{
8988
languages.Add(new DirectoryInfo(directory).Name);
9089
}
@@ -164,36 +163,4 @@ public IEnumerable<string> AvailableLanguages
164163
/// <param name="args">The arguments for the format string</param>
165164
/// <returns>The translated plural format string if n != 1, else the translated non-plural format string for the context</returns>
166165
public string _pn(string context, string text, string pluralText, long n, params object[] args) => _catalog?.GetParticularPluralString(context, text, pluralText, n, args) ?? (n == 1 ? text : pluralText);
167-
168-
/// <summary>
169-
/// Gets the localized help page url for a given page name.
170-
/// </summary>
171-
/// <param name="pageName">The name of the help page</param>
172-
/// <returns>The help page url for the current system locale</returns>
173-
public Uri GetHelpUrl(string pageName)
174-
{
175-
if (OperatingSystem.IsLinux())
176-
{
177-
if (System.Environment.DeploymentMode == DeploymentMode.Flatpak)
178-
{
179-
return new Uri($"help:{_appInfo.EnglishShortName.ToLower()}/{pageName}");
180-
}
181-
}
182-
var lang = "C";
183-
var sysLocale = CultureInfo.CurrentCulture.Name.Replace('-', '_');
184-
if (!string.IsNullOrEmpty(sysLocale) && sysLocale != "C" && sysLocale != "en_US" && sysLocale != "*")
185-
{
186-
var twoLetter = sysLocale.Split('_')[0];
187-
foreach (var language in AvailableLanguages)
188-
{
189-
if (language != sysLocale && language != twoLetter)
190-
{
191-
continue;
192-
}
193-
lang = language;
194-
break;
195-
}
196-
}
197-
return new Uri($"https://htmlpreview.github.io/?{_appInfo.DocumentationStore}/{lang}/{pageName}.html");
198-
}
199166
}

‎Nickvision.Desktop/Globalization/ITranslationService.cs‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32

43
namespace Nickvision.Desktop.Globalization;
@@ -108,13 +107,6 @@ public interface ITranslationService : IService
108107
/// <returns>The translated format string</returns>
109108
string Get(string text, params object[] args) => _(text, args);
110109

111-
/// <summary>
112-
/// Gets the localized help page url for a given page name.
113-
/// </summary>
114-
/// <param name="pageName">The name of the help page</param>
115-
/// <returns>The help page url for the current system locale</returns>
116-
Uri GetHelpUrl(string pageName);
117-
118110
/// <summary>
119111
/// Translates a possible plural string.
120112
/// </summary>

‎Nickvision.Desktop/Nickvision.Desktop.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
99
<EnableWindowsTargeting>true</EnableWindowsTargeting>
1010
<PackageId>Nickvision.Desktop</PackageId>
11-
<Version>2026.2.6</Version>
11+
<Version>2026.2.7</Version>
1212
<Company>Nickvision</Company>
1313
<Authors>Nickvision</Authors>
1414
<Description>A cross-platform base for Nickvision desktop applications.</Description>

‎Nickvision.Desktop/System/Environment.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Globalization;
66
using System.IO;
77
using System.Linq;
8-
using System.Reflection;
98
using System.Runtime.InteropServices;
109

1110
namespace Nickvision.Desktop.System;

0 commit comments

Comments
 (0)