Skip to content

Commit 45bfed3

Browse files
added localization system & added farsi and japanese
1 parent 79ffd08 commit 45bfed3

12 files changed

+512
-91
lines changed

UnityHubNative.Net/AboutDialogue.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected override void OnOpened(EventArgs e)
4444
([
4545
new TextBlock
4646
{
47-
Text = "Unity Hub Native .Net " + Manifest.Version,
47+
Text = UnityHubNativeNetApp.Config.language.TitleBar + " " + Manifest.Version,
4848
FontSize = 25,
4949
HorizontalAlignment = HorizontalAlignment.Center,
5050
}.SetDock(Dock.Top),
@@ -55,12 +55,12 @@ protected override void OnOpened(EventArgs e)
5555
}.SetDock(Dock.Top),
5656
new TextBlock
5757
{
58-
Text = "Developed with Avalonia and inspired by UnityHubNative",
58+
Text = UnityHubNativeNetApp.Config.language.About_1,
5959
HorizontalAlignment = HorizontalAlignment.Center
6060
}.SetDock(Dock.Top),
6161
_btn = new Button
6262
{
63-
Content = "Close",
63+
Content = UnityHubNativeNetApp.Config.language.Close,
6464
HotKey = new(Key.Escape),
6565
HorizontalAlignment = HorizontalAlignment.Center
6666
}.OnClick(Close)

UnityHubNative.Net/ControlsExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ public static T SetTooltip<T>(this T control, string tooltip) where T : Control
224224
return control;
225225
}
226226

227+
public static T SetSelectedItem<T>(this T control, int index) where T : SelectingItemsControl
228+
{
229+
control.SelectedIndex = index;
230+
return control;
231+
}
232+
227233
public static T OnSelectionChanged<T>(this T control, Action action) where T : SelectingItemsControl
228234
{
229235
control.SelectionChanged += (_, _) => action();

UnityHubNative.Net/CreateNewProjectDialogue.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sealed class CreateNewProjectDialogue : Window
2020

2121
public CreateNewProjectDialogue()
2222
{
23-
Title = "Create a New Unity Project";
23+
Title = UnityHubNativeNetApp.Config.language.CreateANewUnityProject;
2424
Content = CreateContent();
2525
UpdateVersionSelectionViews();
2626
UpdateTemplateViews();
@@ -47,7 +47,7 @@ protected override async void OnOpened(EventArgs e)
4747

4848
if (UnityHubUtils.UnityInstallations.Count == 0)
4949
{
50-
await MessageBoxManager.GetMessageBoxStandard("Can't create new projects", "No Unity Installations found").ShowAsPopupAsync(this);
50+
await MessageBoxManager.GetMessageBoxStandard(UnityHubNativeNetApp.Config.language.CantCreateNewProjects, UnityHubNativeNetApp.Config.language.NoUnityInstallationsFound).ShowAsPopupAsync(this);
5151
Close();
5252
return;
5353
}
@@ -68,15 +68,15 @@ protected override async void OnOpened(EventArgs e)
6868
([
6969
new TextBlock
7070
{
71-
Text = "Project Name",
71+
Text = UnityHubNativeNetApp.Config.language.ProjectName,
7272
VerticalAlignment = VerticalAlignment.Center,
7373
Width = 100,
7474
}.SetDock(Dock.Left),
7575
_nameTextBox = new TextBox
7676
{
7777
MaxLines = 1,
7878
VerticalAlignment = VerticalAlignment.Center,
79-
Watermark = "New Unity Project"
79+
Watermark = UnityHubNativeNetApp.Config.language.NewUnityProject
8080
}.OnTextChanged(UpdateCreateButtonView),
8181
]).SetDock(Dock.Top),
8282
new DockPanel
@@ -86,13 +86,13 @@ protected override async void OnOpened(EventArgs e)
8686
([
8787
new TextBlock
8888
{
89-
Text = "Location",
89+
Text = UnityHubNativeNetApp.Config.language.Location,
9090
Width = 100,
9191
VerticalAlignment = VerticalAlignment.Center,
9292
}.SetDock(Dock.Left),
9393
new Button
9494
{
95-
Content = "Choose",
95+
Content = UnityHubNativeNetApp.Config.language.Choose,
9696
Margin = new(2)
9797
}.OnClick(OnChooseLocationClicked).SetDock(Dock.Right),
9898
_pathTextBox = new TextBox
@@ -114,7 +114,7 @@ protected override async void OnOpened(EventArgs e)
114114
([
115115
new TextBlock
116116
{
117-
Text = "Select Template For Version",
117+
Text = UnityHubNativeNetApp.Config.language.SelectTemplateForVersion,
118118
VerticalAlignment = VerticalAlignment.Center,
119119
Margin = new(0, 0, 5, 0),
120120
}.SetDock(Dock.Left),
@@ -131,18 +131,18 @@ protected override async void OnOpened(EventArgs e)
131131
([
132132
_createButton = new Button
133133
{
134-
Content = "Create",
134+
Content = UnityHubNativeNetApp.Config.language.Create,
135135
IsEnabled = false,
136136
Margin = new(2),
137137
VerticalAlignment = VerticalAlignment.Center,
138-
}.OnClick(OnCreateClicked).SetTooltip("Create the Unity Project with the specified attributes").SetDock(Dock.Right),
138+
}.OnClick(OnCreateClicked).SetTooltip(UnityHubNativeNetApp.Config.language.CreateTheUnityProjectWithTheSpecifiedAttributes).SetDock(Dock.Right),
139139
new Button
140140
{
141-
Content = "Cancel",
141+
Content = UnityHubNativeNetApp.Config.language.Cancel,
142142
HotKey = new(Key.Escape),
143143
VerticalAlignment = VerticalAlignment.Center,
144144
Margin = new(2),
145-
}.OnClick(OnCancelClicked).SetTooltip("Cancel the creation of a new Unity Project").SetDock(Dock.Right),
145+
}.OnClick(OnCancelClicked).SetTooltip(UnityHubNativeNetApp.Config.language.CancelTheCreationOfANewUnityProject).SetDock(Dock.Right),
146146
]).SetDock(Dock.Bottom),
147147
_templatesParent = new ListBox
148148
{
@@ -231,7 +231,7 @@ async void OnChooseLocationClicked(Button button, RoutedEventArgs args)
231231
var path = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
232232
{
233233
AllowMultiple = false,
234-
Title = "Select where to write the Unity project"
234+
Title = UnityHubNativeNetApp.Config.language.SelectWhereToWriteTheUnityProject
235235
});
236236
if (path is null || path.Count == 0 || path[0] is null)
237237
return;
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
namespace UnityHubNative.Net;
2+
3+
public interface ILocalization
4+
{
5+
public static readonly ILocalization[] AllLocalizations =
6+
[
7+
new LocalizationEnglish(),
8+
new LocalizationFarsi(),
9+
new LocalizationNihongo()
10+
];
11+
12+
public static bool TryGetFromCode(string code, out ILocalization localization)
13+
{
14+
for (int i = 0; i < AllLocalizations.Length; i++)
15+
if (AllLocalizations[i].LanguageCode == code)
16+
{
17+
localization = AllLocalizations[i];
18+
return true;
19+
}
20+
localization = null;
21+
return false;
22+
}
23+
24+
abstract string LanguageName { get; }
25+
abstract string LanguageCode { get; }
26+
abstract string TitleBar { get; }
27+
abstract string Menu_File { get; }
28+
abstract string Menu_CreateNewProject { get; }
29+
abstract string Menu_AddExistingProject { get; }
30+
abstract string Menu_ReloadData { get; }
31+
abstract string Menu_Project { get; }
32+
abstract string Menu_Window { get; }
33+
abstract string Menu_CloseWindow { get; }
34+
abstract string Menu_About { get; }
35+
abstract string Tab_Projects { get; }
36+
abstract string Tab_UnityVersions { get; }
37+
abstract string Tab_Options { get; }
38+
abstract string SearchProjects { get; }
39+
abstract string InstallSearchPaths { get; }
40+
abstract string AddLocation { get; }
41+
abstract string AddsANewUnitySearchPath { get; }
42+
abstract string RemoveLocation { get; }
43+
abstract string RemovesTheSelectedUnitySearchPathItem { get; }
44+
abstract string DetectedInstallations { get; }
45+
abstract string InstallNew { get; }
46+
abstract string InstallANewUnityEditorVersion { get; }
47+
abstract string Reload { get; }
48+
abstract string ReloadTheList { get; }
49+
abstract string Appearance { get; }
50+
abstract string ControlTheAppearenceOfTheAppCanAffectPerformance { get; }
51+
abstract string TransparentWindow { get; }
52+
abstract string Language { get; }
53+
abstract string MakesTheWindowTransparentUsesMicaOnWindowsAndTheDesktopsBlurOnLinuxNeedsRestartToTakeEffect { get; }
54+
abstract string Acrilyc { get; }
55+
abstract string UseAcrylicBlurOnlyWorksOnWindowsNeedsRestartToTakeEffect { get; }
56+
abstract string BackgroundBlurIntensity { get; }
57+
abstract string ChangesTheIntensityOfTheBackgroundBlur { get; }
58+
abstract string ExtendToTitlebar { get; }
59+
abstract string ExtendsTheClientAreaToTheTitlebar { get; }
60+
abstract string Behaviour { get; }
61+
abstract string CloseAfterOpeningAProject { get; }
62+
abstract string IfCheckedTheAppWillCloseAfterOpeningAProject { get; }
63+
abstract string FormatToOpenProjectInTerminal { get; }
64+
abstract string CloseAfterOpenInTerminal { get; }
65+
abstract string WhetherOrNotToCloseTheAppAfterOpeningProjectInTerminal { get; }
66+
abstract string DefinesTheProcessFormatOfWhenOpeningAProjectInTerminalPathWillBeReplacedByTheProjectPath { get; }
67+
abstract string RememberUnityProjectSelection { get; }
68+
abstract string IfCheckedTheLastSelectedUnityProjectWillBeKeptAcrossSessions { get; }
69+
abstract string Menu_Open { get; }
70+
abstract string Menu_OpenWith { get; }
71+
abstract string Menu_OpenInTerminal { get; }
72+
abstract string Menu_RemoveFromList { get; }
73+
abstract string Menu_RevealInFileExplorer { get; }
74+
abstract string Menu_MoveUpInList { get; }
75+
abstract string Menu_MoveDownInList { get; }
76+
abstract string PickFolderToSearchForUnityInstallations { get; }
77+
abstract string SelectTheFoldersContainingTheUnityProject { get; }
78+
abstract string ProjectHasAlreadyBeenAdded { get; }
79+
abstract string CannotAddProject { get; }
80+
abstract string Error { get; }
81+
abstract string About_1 { get; }
82+
abstract string Close { get; }
83+
abstract string CreateANewUnityProject { get; }
84+
abstract string CantCreateNewProjects { get; }
85+
abstract string NoUnityInstallationsFound { get; }
86+
abstract string ProjectName { get; }
87+
abstract string NewUnityProject { get; }
88+
abstract string Location { get; }
89+
abstract string Choose { get; }
90+
abstract string SelectTemplateForVersion { get; }
91+
abstract string Create { get; }
92+
abstract string CreateTheUnityProjectWithTheSpecifiedAttributes { get; }
93+
abstract string Cancel { get; }
94+
abstract string CancelTheCreationOfANewUnityProject { get; }
95+
abstract string SelectWhereToWriteTheUnityProject { get; }
96+
abstract string CurrentPlatform { get; }
97+
abstract string Platform_Windows { get; }
98+
abstract string Platform_MacOs { get; }
99+
abstract string Platform_Linux { get; }
100+
abstract string Platform_iOS { get; }
101+
abstract string Platform_Android { get; }
102+
abstract string Platform_WebGL { get; }
103+
abstract string Platform_UWP { get; }
104+
abstract string OpenWithSpecificEditor { get; }
105+
abstract string SelectEditorVerisonToOpen { get; }
106+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
using UnityHubNative.Net;
2+
3+
class LocalizationEnglish : ILocalization
4+
{
5+
public string LanguageName => "English";
6+
public string LanguageCode => "en";
7+
public string TitleBar => "UnityHubNative.Net";
8+
public string Menu_File => "_File";
9+
public string Menu_CreateNewProject => "_Create New Project";
10+
public string Menu_AddExistingProject => "_Add Existing Project";
11+
public string Menu_ReloadData => "_Reload Data";
12+
public string Menu_Project => "_Project";
13+
public string Menu_Window => "_Window";
14+
public string Menu_CloseWindow => "_Close Window";
15+
public string Menu_About => "_About UnityHubNative.Net";
16+
public string Tab_Projects => "Projects";
17+
public string Tab_UnityVersions => "Unity Versions";
18+
public string Tab_Options => "Options";
19+
public string SearchProjects => "Search Projects";
20+
public string InstallSearchPaths => "Install Search Paths";
21+
public string AddLocation => "Add Location";
22+
public string AddsANewUnitySearchPath => "Adds a new Unity search path";
23+
public string RemoveLocation => "Remove\nLocation";
24+
public string RemovesTheSelectedUnitySearchPathItem => "Removes the selected Unity search path item";
25+
public string DetectedInstallations => "Detected Installations";
26+
public string InstallNew => "Install New";
27+
public string InstallANewUnityEditorVersion => "Install a new Unity Editor version";
28+
public string Reload => "Reload";
29+
public string ReloadTheList => "Reload the list";
30+
public string Appearance => "Appearance";
31+
public string ControlTheAppearenceOfTheAppCanAffectPerformance => "Control the appearence of the app. Can affect performance.";
32+
public string TransparentWindow => "Transparent Window";
33+
public string Language => "Language";
34+
public string MakesTheWindowTransparentUsesMicaOnWindowsAndTheDesktopsBlurOnLinuxNeedsRestartToTakeEffect => "Makes the window transparent. Uses Mica on Windows and the desktop's blur on Linux.\nNeeds restart to take effect.";
35+
public string Acrilyc => "Acrilyc";
36+
public string UseAcrylicBlurOnlyWorksOnWindowsNeedsRestartToTakeEffect => "Use Acrylic blur. Only works on Windows.\nNeeds restart to take effect.";
37+
public string BackgroundBlurIntensity => "Background Blur Intensity";
38+
public string ChangesTheIntensityOfTheBackgroundBlur => "Changes the intensity of the background blur.";
39+
public string ExtendToTitlebar => "Extend to Titlebar";
40+
public string ExtendsTheClientAreaToTheTitlebar => "Extends the client area to the titlebar.";
41+
public string Behaviour => "Behaviour";
42+
public string CloseAfterOpeningAProject => "Close after opening a project";
43+
public string IfCheckedTheAppWillCloseAfterOpeningAProject => "If checked, the app will close after opening a project";
44+
public string FormatToOpenProjectInTerminal => "Format to open project in Terminal";
45+
public string CloseAfterOpenInTerminal => "Close after open in terminal";
46+
public string WhetherOrNotToCloseTheAppAfterOpeningProjectInTerminal => "Whether or not to close the app after opening project in terminal";
47+
public string DefinesTheProcessFormatOfWhenOpeningAProjectInTerminalPathWillBeReplacedByTheProjectPath => "Defines the process format of when opening a project in terminal. {path} will be replaced by the project path";
48+
public string RememberUnityProjectSelection => "Remember Unity Project selection";
49+
public string IfCheckedTheLastSelectedUnityProjectWillBeKeptAcrossSessions => "If checked, the last selected Unity Project will be kept across sessions";
50+
public string Menu_Open => "Open";
51+
public string Menu_OpenWith => "Open With";
52+
public string Menu_OpenInTerminal => "Open In Terminal";
53+
public string Menu_RemoveFromList => "R_emove From List";
54+
public string Menu_RevealInFileExplorer => "_Reveal In File Explorer";
55+
public string Menu_MoveUpInList => "Move Up In List";
56+
public string Menu_MoveDownInList => "Move Down In List";
57+
public string PickFolderToSearchForUnityInstallations => "Pick Folder to search for Unity Installations";
58+
public string SelectTheFoldersContainingTheUnityProject => "Select the folder(s) containing the Unity Project";
59+
public string ProjectHasAlreadyBeenAdded => "Project \"{0}\" has already been added.";
60+
public string CannotAddProject => "Cannot add project";
61+
public string Error => "Error";
62+
public string About_1 => "Developed with Avalonia and inspired by UnityHubNative";
63+
public string Close => "Close";
64+
public string CreateANewUnityProject => "Create a New Unity Project";
65+
public string CantCreateNewProjects => "Can't create new projects";
66+
public string NoUnityInstallationsFound => "No Unity Installations found";
67+
public string ProjectName => "Project Name";
68+
public string NewUnityProject => "New Unity Project";
69+
public string Location => "Location";
70+
public string Choose => "Choose";
71+
public string SelectTemplateForVersion => "Select Template For Version";
72+
public string Create => "Create";
73+
public string CreateTheUnityProjectWithTheSpecifiedAttributes => "Create the Unity Project with the specified attributes";
74+
public string Cancel => "Cancel";
75+
public string CancelTheCreationOfANewUnityProject => "Cancel the creation of a new Unity Project";
76+
public string SelectWhereToWriteTheUnityProject => "Select where to write the Unity project";
77+
public string CurrentPlatform => "Current Platform";
78+
public string Platform_Windows => "Windows";
79+
public string Platform_MacOs => "MacOs";
80+
public string Platform_Linux => "Linux";
81+
public string Platform_iOS => "iOS";
82+
public string Platform_Android => "Android";
83+
public string Platform_WebGL => "WebGL";
84+
public string Platform_UWP => "UWP";
85+
public string OpenWithSpecificEditor => "Open With Specific Editor";
86+
public string SelectEditorVerisonToOpen => "Select editor verison to open \"{0}\"";
87+
}

0 commit comments

Comments
 (0)