-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
throw exceptions if required
- Loading branch information
Showing
5 changed files
with
61 additions
and
24 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
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
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,20 @@ | ||
using System; | ||
using UnityEditor; | ||
|
||
namespace UnityTextI18n | ||
{ | ||
public class I18NEditorWindow : EditorWindow | ||
{ | ||
[MenuItem("I18N/Editor")] | ||
private static void Init() | ||
{ | ||
var editorWindow = GetWindow(typeof(I18NEditorWindow)); | ||
editorWindow.Show(); | ||
} | ||
|
||
private void OnGUI() | ||
{ | ||
throw new NotImplementedException("Tepache Labs is working on this..."); | ||
} | ||
} | ||
} |
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,33 @@ | ||
using System; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace UnityTextI18n | ||
{ | ||
[RequireComponent(typeof(Text))] | ||
[AddComponentMenu("UI/I18NText", 10)] | ||
public class I18NText : MonoBehaviour | ||
{ | ||
private const string TranslationIdNotFoundInTheI18NOptions = "translationId not found in the i18n resource file"; | ||
|
||
[SerializeField] protected string translationId = string.Empty; | ||
private void Start() | ||
{ | ||
var text = GetComponent<Text>(); | ||
if (text == null) return; | ||
|
||
if (!I18N.Language.ContainsKey(translationId)) | ||
{ | ||
throw new NotSupportedException(TranslationIdNotFoundInTheI18NOptions); | ||
} | ||
|
||
Translate(text); | ||
} | ||
|
||
private void Translate(Text textComponent) | ||
{ | ||
textComponent.text = translationId == string.Empty ? | ||
I18N.GetLanguageCode() : I18N.Language[translationId]; | ||
} | ||
} | ||
} |
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