Note: this fork goes against Dreadrith’s, the Original Author, wishes. Is is however compliant with the original OS license.
A framework allowing for easy Localization of scripts in Unity.
Unity-Localization-Core is framework for Unity script localization. It comes with a handy UI and clean interface for localization.
It can be used in two ways:
To allow for a nice overview during translation, you can use the Unity-Localization-Inspector package.
There are two options here, either:
As a dependency:
or bundled:
To start off, create a class that inherits from LocalizationScriptableBase, with a title in the “hostTitle” field.
public class AV3ManagerLocalization : LocalizationScriptableBase
{
public override string hostTitle => "Avatar 3.0 Manager Localization";
}
Then, create an enum containing the values you want for every category (for now we’ll only do one).
public class AV3ManagerLocalization : LocalizationScriptableBase
{
public override string hostTitle => "Avatar 3.0 Manager Localization";
public enum Keys
{
Merger_AnimatorMode,
Merger_Animator,
Merger_Parameters,
Merger_Suffix,
Merger_SelfMergeWarning,
...
}
}
Afterwards, return a list of KeyCollections with their names and values for the keyCollections property.
public class AV3ManagerLocalization : LocalizationScriptableBase
{
public override string hostTitle => "Avatar 3.0 Manager Localization";
public override KeyCollection[] keyCollections => new[] { new KeyCollection("Avatar 3.0 Manager Localization", typeof(Keys)) };
public enum Keys
{
Merger_AnimatorMode,
Merger_Animator,
Merger_Parameters,
Merger_Suffix,
Merger_SelfMergeWarning,
...
}
}
Now, you can use it in the code (here the class is instantiated as a singleton, but you can do this however you want):
private static LocalizationHandler<AV3ManagerLocalization> _localizationHandler;
public static LocalizationHandler<AV3ManagerLocalization> LocalizationHandler
{
get
{
if (_localizationHandler == null)
_localizationHandler = new LocalizationHandler<AV3ManagerLocalization>();
return _localizationHandler;
}
}
...
public void OnGui()
{
EditorGUILayout.Label(LocalizationHandler.Get(Merger_AnimatorMode).text);
}
Now to let the user choose their own language, you can call LocalizationHandler.DrawField()
on your LocalizationHandler, and the dropdown will be drawn for you.
For this part, you have to use Unity-Localization-Inspector package.
Unity-Localization-Core is available as-is under MIT. For more information see LICENSE.
dev.vrlabs.unity-localization-core
未設定
1.0.0
2019.4 以降
なし
なし
なし