// // /*===============================================================================
// // Copyright (C) 2024 PhantomsXR Ltd. All Rights Reserved.
// //
// // This file is part of the Phantom.XRMOD.Localization.Runtime.
// //
// // The Localization cannot be copied, distributed, or made available to
// // third-parties for commercial purposes without written permission of PhantomsXR Ltd.
// //
// // Contact nswell@phantomsxr.com for licensing requests.
// // ===============================================================================*/
namespace Phantom.XRMOD.Localization.Runtime
{
public static class LocalizedStringKeyExtension
{
///
/// Get the localized string from specified localization module.
///
/// The localization key.
/// Specified localization module.
/// The localized string.
public static string Localized(this string _key, LocalizationModule _module)
{
return _module == null ? string.Empty : _module.GetLocalizedString(_key);
}
///
/// Get the localized string from LocalizationManager.
///
/// The localization key.
/// Workspace
/// The localized string.
public static string Localized(this string _key, LocalizationScope _localizationScope = LocalizationScope.InExperiences)
{
return LocalizationManager.Instance.GetLocalizedString(_key, _localizationScope);
}
///
/// Get the localized string from LocalizationManager.
/// But you can modify at runtime.
///
/// The localization key.
/// The dynamic value from script
/// Workspace
/// The localized string with your dynamic value.
public static string Localized(this string _key, string _dynamicValue,
LocalizationScope _localizationScope = LocalizationScope.InExperiences)
{
return string.Format(LocalizationManager.Instance.GetLocalizedString(_key, _localizationScope), _dynamicValue);
}
///
/// Get the localized string from LocalizationManager.
/// But you can modify at runtime.
///
/// The localization key.
/// The dynamic values from script
/// Workspace
/// The localized string with your dynamic values.
public static string Localized(this string _key, LocalizationScope _localizationScope = LocalizationScope.InExperiences,
params object[] _dynamicValues)
{
return string.Format(LocalizationManager.Instance.GetLocalizedString(_key, _localizationScope),
_dynamicValues);
}
}
}