Skip to content

Commit

Permalink
i18n & fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pd233 committed Jan 15, 2024
1 parent 3e08a9c commit 2059f04
Show file tree
Hide file tree
Showing 17 changed files with 310 additions and 43 deletions.
87 changes: 87 additions & 0 deletions src/LipUI/Language/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="application$restart" xml:space="preserve">
<value>Restart</value>
</data>
<data name="application$restartMessage" xml:space="preserve">
<value>Need to restart application.</value>
</data>
<data name="autoSuggestBox$search.PlaceholderText" xml:space="preserve">
<value>Search</value>
</data>
Expand All @@ -126,6 +132,21 @@
<data name="eula$deny" xml:space="preserve">
<value>Disagree</value>
</data>
<data name="generalSettings$githubApi.Text" xml:space="preserve">
<value>GitHub API</value>
</data>
<data name="generalSettings$githubProxy.Text" xml:space="preserve">
<value>Github proxy</value>
</data>
<data name="generalSettings$lipIndexApi.Text" xml:space="preserve">
<value>Lip Index API</value>
</data>
<data name="generalSettings$lipPath.Text" xml:space="preserve">
<value>Lip path</value>
</data>
<data name="generalSettings$title.Text" xml:space="preserve">
<value>General settings</value>
</data>
<data name="home$emptyDesc" xml:space="preserve">
<value>No description</value>
</data>
Expand All @@ -144,6 +165,9 @@
<data name="lipExecution$nullLipPath" xml:space="preserve">
<value>Unknown Lip path!</value>
</data>
<data name="lipExecution$nullServerPath" xml:space="preserve">
<value>Unknown server path!</value>
</data>
<data name="lipInstaller$cancel.Content" xml:space="preserve">
<value>Cancel</value>
</data>
Expand All @@ -165,6 +189,15 @@
<data name="localTooth$update" xml:space="preserve">
<value>Update</value>
</data>
<data name="moduleManager$modules.Text" xml:space="preserve">
<value>Modules</value>
</data>
<data name="moduleManager$plugins.Text" xml:space="preserve">
<value>Plugins</value>
</data>
<data name="moduleManager$UIplugins.Text" xml:space="preserve">
<value>UI Plugins</value>
</data>
<data name="modules$title$allowListViewer" xml:space="preserve">
<value>Allowlist</value>
</data>
Expand All @@ -183,9 +216,63 @@
<data name="navigationView$moduleManager.Content" xml:space="preserve">
<value>Module manager</value>
</data>
<data name="navigationView$More.Content" xml:space="preserve">
<value>More</value>
</data>
<data name="navigationView$packageIndex.Content" xml:space="preserve">
<value>Lip index</value>
</data>
<data name="personalizationSettings$backdrop$acrylic" xml:space="preserve">
<value>Acrylic</value>
</data>
<data name="personalizationSettings$backdrop$mica" xml:space="preserve">
<value>Mica</value>
</data>
<data name="personalizationSettings$backdrop$none" xml:space="preserve">
<value>None</value>
</data>
<data name="personalizationSettings$backdrop$transparent" xml:space="preserve">
<value>Transparent</value>
</data>
<data name="personalizationSettings$background.Header" xml:space="preserve">
<value>Background</value>
</data>
<data name="personalizationSettings$backgroundColor.Text" xml:space="preserve">
<value>Background color</value>
</data>
<data name="personalizationSettings$backgroundColorSecondary.Text" xml:space="preserve">
<value>Background color secondary</value>
</data>
<data name="personalizationSettings$clearImage.Content" xml:space="preserve">
<value>Clear image</value>
</data>
<data name="personalizationSettings$dark.Text" xml:space="preserve">
<value>Dark</value>
</data>
<data name="personalizationSettings$default.Text" xml:space="preserve">
<value>Default</value>
</data>
<data name="personalizationSettings$enableImageBackground.Content" xml:space="preserve">
<value>Enable background image</value>
</data>
<data name="personalizationSettings$light.Text" xml:space="preserve">
<value>Light</value>
</data>
<data name="personalizationSettings$luminosityOpacity.Header" xml:space="preserve">
<value>Luminosity opacity</value>
</data>
<data name="personalizationSettings$navViewBackgroundColor.Text" xml:space="preserve">
<value>Navigation view content background color</value>
</data>
<data name="personalizationSettings$navViewBorderColor.Text" xml:space="preserve">
<value>Navigation view content border color</value>
</data>
<data name="personalizationSettings$selectImage.Content" xml:space="preserve">
<value>Select image</value>
</data>
<data name="personalizationSettings$title.Text" xml:space="preserve">
<value>Personalization</value>
</data>
<data name="propertiesEditor$nullServerPath" xml:space="preserve">
<value>Unknown server path!</value>
</data>
Expand Down
87 changes: 87 additions & 0 deletions src/LipUI/Language/zh-CN/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="application$restart" xml:space="preserve">
<value>立即重启</value>
</data>
<data name="application$restartMessage" xml:space="preserve">
<value>需要重启应用</value>
</data>
<data name="autoSuggestBox$search.PlaceholderText" xml:space="preserve">
<value>搜索</value>
</data>
Expand All @@ -126,6 +132,21 @@
<data name="eula$deny" xml:space="preserve">
<value>不同意</value>
</data>
<data name="generalSettings$githubApi.Text" xml:space="preserve">
<value>GitHub API</value>
</data>
<data name="generalSettings$githubProxy.Text" xml:space="preserve">
<value>Github代理</value>
</data>
<data name="generalSettings$lipIndexApi.Text" xml:space="preserve">
<value>Lip Index API</value>
</data>
<data name="generalSettings$lipPath.Text" xml:space="preserve">
<value>Lip路径</value>
</data>
<data name="generalSettings$title.Text" xml:space="preserve">
<value>常规</value>
</data>
<data name="home$emptyDesc" xml:space="preserve">
<value>无描述</value>
</data>
Expand All @@ -144,6 +165,9 @@
<data name="lipExecution$nullLipPath" xml:space="preserve">
<value>未知的Lip路径!</value>
</data>
<data name="lipExecution$nullServerPath" xml:space="preserve">
<value>未知的服务器路径!</value>
</data>
<data name="lipInstaller$cancel.Content" xml:space="preserve">
<value>取消</value>
</data>
Expand All @@ -165,6 +189,15 @@
<data name="localTooth$update" xml:space="preserve">
<value>更新</value>
</data>
<data name="moduleManager$modules.Text" xml:space="preserve">
<value>组件</value>
</data>
<data name="moduleManager$plugins.Text" xml:space="preserve">
<value>插件</value>
</data>
<data name="moduleManager$UIplugins.Text" xml:space="preserve">
<value>UI插件</value>
</data>
<data name="modules$title$allowListViewer" xml:space="preserve">
<value>白名单</value>
</data>
Expand All @@ -183,9 +216,63 @@
<data name="navigationView$moduleManager.Content" xml:space="preserve">
<value>组件管理</value>
</data>
<data name="navigationView$More.Content" xml:space="preserve">
<value>更多</value>
</data>
<data name="navigationView$packageIndex.Content" xml:space="preserve">
<value>包索引</value>
</data>
<data name="personalizationSettings$backdrop$acrylic" xml:space="preserve">
<value>亚克力</value>
</data>
<data name="personalizationSettings$backdrop$mica" xml:space="preserve">
<value>云母</value>
</data>
<data name="personalizationSettings$backdrop$none" xml:space="preserve">
<value>无</value>
</data>
<data name="personalizationSettings$backdrop$transparent" xml:space="preserve">
<value>透明</value>
</data>
<data name="personalizationSettings$background.Header" xml:space="preserve">
<value>背景</value>
</data>
<data name="personalizationSettings$backgroundColor.Text" xml:space="preserve">
<value>背景颜色</value>
</data>
<data name="personalizationSettings$backgroundColorSecondary.Text" xml:space="preserve">
<value>二级背景颜色</value>
</data>
<data name="personalizationSettings$clearImage.Content" xml:space="preserve">
<value>清除图片</value>
</data>
<data name="personalizationSettings$dark.Text" xml:space="preserve">
<value>深色</value>
</data>
<data name="personalizationSettings$default.Text" xml:space="preserve">
<value>默认</value>
</data>
<data name="personalizationSettings$enableImageBackground.Content" xml:space="preserve">
<value>启用背景图片</value>
</data>
<data name="personalizationSettings$light.Text" xml:space="preserve">
<value>浅色</value>
</data>
<data name="personalizationSettings$luminosityOpacity.Header" xml:space="preserve">
<value>不透明度</value>
</data>
<data name="personalizationSettings$navViewBackgroundColor.Text" xml:space="preserve">
<value>导航视图内容背景颜色</value>
</data>
<data name="personalizationSettings$navViewBorderColor.Text" xml:space="preserve">
<value>导航视图内容边框颜色</value>
</data>
<data name="personalizationSettings$selectImage.Content" xml:space="preserve">
<value>选择图片</value>
</data>
<data name="personalizationSettings$title.Text" xml:space="preserve">
<value>个性化</value>
</data>
<data name="propertiesEditor$nullServerPath" xml:space="preserve">
<value>未知的服务器路径!</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletion src/LipUI/LipUI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>

<!--<WindowsPackageType>None</WindowsPackageType>-->
<WindowsPackageType>None</WindowsPackageType>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>

<OutputType>WinExe</OutputType>
Expand Down
2 changes: 1 addition & 1 deletion src/LipUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<NavigationViewItem
x:Name="NavigationViewItem_More"
Icon="More"
Content="i18n.more"
x:Uid="navigationView$More"
SelectsOnInvoked="False"/>

<NavigationViewItemSeparator/>
Expand Down
9 changes: 6 additions & 3 deletions src/LipUI/Models/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class GeneralSetting

[JsonPropertyName("github_api")]
public string GithubApiKey { get; set; } = string.Empty;

[JsonPropertyName("github_proxy")]
public string GithubProxy { get; set; } = string.Empty;
}

public class PersonalizationSetting
Expand Down Expand Up @@ -88,15 +91,15 @@ public class PersonalizationSetting
[JsonPropertyName("personalization_settings")]
public PersonalizationSetting PersonalizationSettings { get; set; }

[JsonPropertyName("plugin_enable_info")]
public Dictionary<string, bool> PluginEanbleInfo { get; set; }

[JsonPropertyName("servers")]
public List<ServerInstance> ServerInstances { get; set; }

[JsonPropertyName("selected_server")]
public ServerInstance? SelectedServer { get; set; }

[JsonPropertyName("plugin_enable_info")]
public Dictionary<string, bool> PluginEanbleInfo { get; set; }

public Config()
{
ServerInstances = new();
Expand Down
6 changes: 4 additions & 2 deletions src/LipUI/Models/Plugin/PluginSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public static async ValueTask LoadAsync()
var types = from type in Assembly.GetExecutingAssembly().GetTypes()
where type.IsAssignableTo(typeof(ILipuiPlugin)) && type.GetCustomAttribute<LipUIModuleAttribute>() is not null
select type;

pluginTypes.AddRange(types);

foreach (var file in dirInfo.EnumerateFiles())
Expand Down Expand Up @@ -165,15 +166,16 @@ public static string GetPluginEnabledConfigKey(ILipuiPlugin plugin)

private static async ValueTask EnablePlugins(IEnumerable<ILipuiPlugin> plugins)
{
var enableInfo = Main.Config.PluginEanbleInfo;
Main.Config.PluginEanbleInfo = new();
foreach (var plugin in plugins)
{
var key = GetPluginEnabledConfigKey(plugin);
try
{
if (Main.Config.PluginEanbleInfo.TryGetValue(key, out bool enable) is false)
if (enableInfo.TryGetValue(key, out bool enable) is false)
{
enable = plugin.DefaultEnabled;
Main.Config.PluginEanbleInfo.Add(key, enable);
}

if (enable)
Expand Down
5 changes: 3 additions & 2 deletions src/LipUI/Pages/Home/Modules/BdsPropertiesEditorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private async void Page_Loaded(object sender, RoutedEventArgs e)
if (Server is null)
{
await Task.Delay(500);
await ShowInfoBarAsync("propertiesEditor$nullServerPath".GetLocalized(), severity: InfoBarSeverity.Error);
ShowInfoBar("propertiesEditor$nullServerPath".GetLocalized(), severity: InfoBarSeverity.Error);
Frame.TryGoBack();
return;
};
Expand Down Expand Up @@ -130,7 +130,8 @@ private async void LoadPropertiesAndCreateUI()
}
catch (Exception ex)
{
await ShowInfoBarAsync(ex);
ShowInfoBar(ex);
await Task.Delay(1000);
Frame.TryGoBack();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,13 @@ public void Run()

await InternalServices.ShowInfoBarAsync(
"infobar$error".GetLocalized(),
Main.Config.SelectedServer is null ?
"lipExecution$nullServerPath".GetLocalized() :
"lipExecution$nullLipPath".GetLocalized(),
InfoBarSeverity.Error);

page.Frame.TryGoBack();

return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/LipUI/Pages/LipExecutionPanel/LipInstallerView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private async ValueTask<byte[]> DownloadLipPortable(InstallerInfo info)
catch (Exception ex)
{
await InternalServices.ShowInfoBarAsync(ex, severity: InfoBarSeverity.Warning);
response = await client.GetAsync($"https://github.moeyy.xyz/{info.AssetUrl}");
response = await client.GetAsync($"{Main.Config.GeneralSettings.GithubProxy}/{info.AssetUrl}");
}

var input = await response.Content.ReadAsStreamAsync();
Expand Down
6 changes: 3 additions & 3 deletions src/LipUI/Pages/ModuleManager/ModuleManagerPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<TextBlock
HorizontalAlignment="Center"
Text="i18n.plugins"/>
x:Uid="moduleManager$plugins"/>

</Button>

Expand All @@ -50,7 +50,7 @@

<TextBlock
HorizontalAlignment="Center"
Text="i18n.UIplugins"/>
x:Uid="moduleManager$UIplugins"/>

</Button>

Expand All @@ -66,7 +66,7 @@

<TextBlock
HorizontalAlignment="Center"
Text="i18n.Modules"/>
x:Uid="moduleManager$modules"/>

</Button>

Expand Down
Loading

0 comments on commit 2059f04

Please sign in to comment.