-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace UnityVolumeRendering | ||
{ | ||
public class LocalisationManager | ||
{ | ||
private enum Locale | ||
{ | ||
English, | ||
Chinese | ||
} | ||
|
||
private struct LocalisationEntry | ||
{ | ||
public string english; | ||
public string chineseSimplified; | ||
} | ||
|
||
private static Locale currentLocale = Locale.English; | ||
|
||
private static Dictionary<string, LocalisationEntry> translations = new Dictionary<string, LocalisationEntry>() | ||
{ | ||
{"MenuBar:VolumeRendering", new LocalisationEntry { | ||
english= "Volume Rendering", | ||
chineseSimplified= "体绘制" | ||
}}, | ||
{"MenuBar:LoadDataset", new LocalisationEntry { | ||
english= "Load dataset", | ||
chineseSimplified= "导入数据集" | ||
}}, | ||
{"MenuBar:LoadDICOM", new LocalisationEntry { | ||
english= "Load DICOM", | ||
chineseSimplified= "导入DICOM数据" | ||
}}, | ||
{"MenuBar:LoadRaw", new LocalisationEntry { | ||
english= "Load raw dataset", | ||
chineseSimplified= "导入RAW数据" | ||
}}, | ||
{"MenuBar:LoadNRRD", new LocalisationEntry { | ||
english= "Load NRRD dataset", | ||
chineseSimplified= "导入NRRD数据" | ||
}}, | ||
{"MenuBar:LoadNIFTI", new LocalisationEntry { | ||
english= "Load NIFTI dataset", | ||
chineseSimplified= "导入NIFTI数据" | ||
}}, | ||
{"MenuBar:LoadPARCHG", new LocalisationEntry { | ||
english= "Load PARCHG dataset", | ||
chineseSimplified= "导入PARCHG数据" | ||
}}, | ||
{"MenuBar:LoadNIFTI", new LocalisationEntry { | ||
english= "Load image sequence dataset", | ||
chineseSimplified= "导入图像序列格式" | ||
}} | ||
}; | ||
|
||
static LocalisationManager() | ||
{ | ||
currentLocale = Locale.English; | ||
#if UNITY_EDITOR | ||
if (UnityEditor.EditorPrefs.GetString("Editor.kEditorLocale") == "ChineseSimplified") | ||
currentLocale = Locale.Chinese; | ||
#endif | ||
if (!Application.isEditor && Application.systemLanguage.ToString() == "ChineseSimplified") | ||
currentLocale = Locale.Chinese; | ||
} | ||
|
||
public static string GetString(string id) | ||
{ | ||
if (!translations.ContainsKey(id)) | ||
{ | ||
Debug.LogWarning("Localisation key not found: " + id); | ||
return ""; | ||
} | ||
LocalisationEntry translation = translations[id]; | ||
return currentLocale == Locale.Chinese ? translation.chineseSimplified : translation.english; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.