mirror of
https://github.com/TheWhiteDog9487/lag2cn.git
synced 2026-08-14 16:21:28 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7335b0bb8 | |||
| aae4cb05d2 |
@@ -32,7 +32,7 @@ jobs:
|
|||||||
alpine:latest /bin/sh -c '
|
alpine:latest /bin/sh -c '
|
||||||
apk update
|
apk update
|
||||||
apk add build-base dotnet10-sdk clang
|
apk add build-base dotnet10-sdk clang
|
||||||
dotnet publish language.cs /t:Rebuild --disable-build-servers --force '
|
dotnet publish language.cs '
|
||||||
- name: 重命名
|
- name: 重命名
|
||||||
if: ${{ matrix.runner == 'ubuntu-26.04-arm' }}
|
if: ${{ matrix.runner == 'ubuntu-26.04-arm' }}
|
||||||
run: sudo mv artifacts/language/language artifacts/language/language_arm
|
run: sudo mv artifacts/language/language artifacts/language/language_arm
|
||||||
|
|||||||
+14
-5
@@ -67,6 +67,7 @@ void ExecuteCommand(string Command,
|
|||||||
|
|
||||||
string OsDescription = RuntimeInformation.OSDescription;
|
string OsDescription = RuntimeInformation.OSDescription;
|
||||||
if (Enum.TryParse<SupportedLinuxDistributions>(OsDescription.Split(' ')[0], out var CurrentSystem) == false){
|
if (Enum.TryParse<SupportedLinuxDistributions>(OsDescription.Split(' ')[0], out var CurrentSystem) == false){
|
||||||
|
// 对于Arch Linux这种系统名称中间有空格的需要特判
|
||||||
if (OsDescription.Contains("Arch Linux")){
|
if (OsDescription.Contains("Arch Linux")){
|
||||||
CurrentSystem = SupportedLinuxDistributions.ArchLinux; }
|
CurrentSystem = SupportedLinuxDistributions.ArchLinux; }
|
||||||
else if (OsDescription.Contains("Rocky Linux")){
|
else if (OsDescription.Contains("Rocky Linux")){
|
||||||
@@ -98,8 +99,10 @@ switch (CurrentSystem){
|
|||||||
CheckUser();
|
CheckUser();
|
||||||
Console.WriteLine("正在检查语言配置");
|
Console.WriteLine("正在检查语言配置");
|
||||||
string[] NewContent = [];
|
string[] NewContent = [];
|
||||||
|
File.Copy("/etc/locale.gen", "/etc/locale.gen.bak", true);
|
||||||
|
Console.WriteLine("原始 /etc/locale.gen 文件已备份为 /etc/locale.gen.bak");
|
||||||
using var FileStream = new FileStream("/etc/locale.gen", FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
using var FileStream = new FileStream("/etc/locale.gen", FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
||||||
using (var StreamReader = new StreamReader(FileStream, Encoding.UTF8, true, 1024, true)){
|
using (var StreamReader = new StreamReader(FileStream, new UTF8Encoding(false), true, 1024, true)){
|
||||||
NewContent = [.. StreamReader.ReadToEnd()
|
NewContent = [.. StreamReader.ReadToEnd()
|
||||||
.Split("\n")
|
.Split("\n")
|
||||||
.Select(Line => Line.Trim())
|
.Select(Line => Line.Trim())
|
||||||
@@ -107,9 +110,15 @@ switch (CurrentSystem){
|
|||||||
if (Line.Contains("zh_CN.UTF-8 UTF-8")){
|
if (Line.Contains("zh_CN.UTF-8 UTF-8")){
|
||||||
Line = "zh_CN.UTF-8 UTF-8"; }
|
Line = "zh_CN.UTF-8 UTF-8"; }
|
||||||
return Line; } ) ]; }
|
return Line; } ) ]; }
|
||||||
|
if (NewContent.Any(Line => Line.StartsWith("zh_CN.UTF-8 UTF-8")) == false){
|
||||||
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
|
Console.WriteLine("警告:在 /etc/locale.gen 中未检测到 zh_CN.UTF-8 UTF-8 条目,这种情况较为反常,建议您关注后续的执行结果");
|
||||||
|
Console.WriteLine("如果需要恢复备份,请直接使用 /etc/locale.gen.bak 覆盖 /etc/locale.gen");
|
||||||
|
Console.ResetColor();
|
||||||
|
NewContent = [.. NewContent, "zh_CN.UTF-8 UTF-8"]; }
|
||||||
FileStream.SetLength(0);
|
FileStream.SetLength(0);
|
||||||
FileStream.Seek(0, SeekOrigin.Begin);
|
FileStream.Seek(0, SeekOrigin.Begin);
|
||||||
using (var StreamWriter = new StreamWriter(FileStream, Encoding.UTF8)){
|
using (var StreamWriter = new StreamWriter(FileStream, new UTF8Encoding(false), 1024, true)){
|
||||||
foreach (var Line in NewContent){
|
foreach (var Line in NewContent){
|
||||||
StreamWriter.WriteLine(Line); } }
|
StreamWriter.WriteLine(Line); } }
|
||||||
Console.WriteLine("正在生成语言配置");
|
Console.WriteLine("正在生成语言配置");
|
||||||
@@ -141,12 +150,12 @@ switch (CurrentSystem){
|
|||||||
CheckUser("即将开始安装中文语言包");
|
CheckUser("即将开始安装中文语言包");
|
||||||
Console.WriteLine("开始更新语言配置");
|
Console.WriteLine("开始更新语言配置");
|
||||||
Console.WriteLine("正在安装中文语言包");
|
Console.WriteLine("正在安装中文语言包");
|
||||||
ExecuteCommand("dnf", ["install", "-y", "--nogpgcheck", "glibc-langpack-zh", "langpacks-zh_CN"]);
|
ExecuteCommand("dnf", ["install", "-y", "glibc-langpack-zh", "langpacks-zh_CN"]);
|
||||||
Console.WriteLine("正在更新语言配置");
|
Console.WriteLine("正在更新语言配置");
|
||||||
ExecuteCommand("localectl", ["set-locale", "LANG=zh_CN.UTF-8"]);
|
ExecuteCommand("localectl", ["set-locale", "LANG=zh_CN.UTF-8"]);
|
||||||
|
|
||||||
if (IsRunningInsideWSL() && CurrentSystem == SupportedLinuxDistributions.AlmaLinux) {
|
if (IsRunningInsideWSL() && CurrentSystem == SupportedLinuxDistributions.AlmaLinux) {
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine("警告:检测到您正在WSL内使用AlmaLinux");
|
Console.WriteLine("警告:检测到您正在WSL内使用AlmaLinux");
|
||||||
Console.WriteLine("目前已知AlmaLinux的WSL镜像可能存在一些问题");
|
Console.WriteLine("目前已知AlmaLinux的WSL镜像可能存在一些问题");
|
||||||
@@ -157,7 +166,7 @@ switch (CurrentSystem){
|
|||||||
break; }
|
break; }
|
||||||
default: {
|
default: {
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Console.WriteLine($"您当前使用的操作系统 {OsDescription} ,匹配名称 {CurrentSystem} 受到支持,但是lag2cn没有为其配置执行逻辑");
|
Console.WriteLine($"错误:您当前使用的操作系统 {OsDescription} ,匹配名称 {CurrentSystem} 受到支持,但是lag2cn没有为其配置执行逻辑");
|
||||||
Console.WriteLine("这是一个程序Bug,请前往Github仓库开启一个issue,并提供当前输出日志");
|
Console.WriteLine("这是一个程序Bug,请前往Github仓库开启一个issue,并提供当前输出日志");
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
throw new InvalidOperationException("遗漏的switch匹配"); } }
|
throw new InvalidOperationException("遗漏的switch匹配"); } }
|
||||||
|
|||||||
Reference in New Issue
Block a user