Skip to content

Instantly share code, notes, and snippets.

@mmoczkowski
Created September 14, 2015 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmoczkowski/bc4526e27598d62f5870 to your computer and use it in GitHub Desktop.
Save mmoczkowski/bc4526e27598d62f5870 to your computer and use it in GitHub Desktop.
namespace Sathra.Localization {
[ExecuteInEditMode]
[RequireComponent(typeof(Text))]
public class Localizer : MonoBehaviour {
#region Inspector
[SerializeField] private int _resId = 0;
#endregion
private Text _label;
private void Awake () {
_label = GetComponent<Text>();
LocalizationManager.LanguageChanged += OnLanguageChanged;
}
private void OnLanguageChanged(SystemLanguage language) {
if(_resId != 0 && _label != null) {
_label.text = LocalizationManager.Instance.GetString(_resId);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment