-
Notifications
You must be signed in to change notification settings - Fork 0
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
13 changed files
with
227 additions
and
7 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
2 changes: 1 addition & 1 deletion
2
...ts/Scripts/Localization/DataHandlers.meta → ...ets/Scripts/Localization/Observables.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
l10n/Assets/Scripts/Localization/Observables/ILocaleChangedEventArgs.cs
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,13 @@ | ||
namespace l10n.Localization.observables | ||
{ | ||
/// <summary> | ||
/// Abstraction for Arguments for the event <see cref="ILocalizationObservable.LocaleChanged"/> | ||
/// </summary> | ||
public interface ILocaleChangedEventArgs | ||
{ | ||
/// <summary> | ||
/// New Language that was selected. | ||
/// </summary> | ||
string NewLocale { get; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
l10n/Assets/Scripts/Localization/Observables/ILocaleChangedEventArgs.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
l10n/Assets/Scripts/Localization/Observables/LocaleChangedEventArgs.cs
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,21 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace l10n.Localization.observables | ||
{ | ||
public class LocaleChangedEventArgs : ILocaleChangedEventArgs | ||
{ | ||
#region Properties | ||
|
||
private readonly string s_newLocale; | ||
public string NewLocale => s_newLocale; | ||
|
||
#endregion | ||
|
||
public LocaleChangedEventArgs(string newLocale) | ||
{ | ||
s_newLocale = newLocale; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
l10n/Assets/Scripts/Localization/Observables/LocaleChangedEventArgs.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
l10n/Assets/Scripts/Localization/Observables/l10nManager.cs
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,63 @@ | ||
using l10n.common; | ||
using l10n.Localization.sources; | ||
using l10n.Localization.translations; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace l10n.Localization.observables | ||
{ | ||
/// <summary> | ||
/// Central Manager for localization settings of the application. | ||
/// Does all localization processing and generation of translations during runtime. | ||
/// </summary> | ||
|
||
public class l10nManager : Singleton<l10nManager>, ILocalizationObservable | ||
{ | ||
|
||
#region Properties | ||
[SerializeField] | ||
private ILocalizationLogger s_logger; | ||
public ILocalizationLogger Logger => s_logger ?? (s_logger = new LocalizationLogger()); | ||
|
||
[SerializeField] | ||
private string s_currentLocale; | ||
public string CurrentLocale | ||
{ | ||
get { return s_currentLocale; } | ||
set | ||
{ | ||
Logger.Log(string.Format("Localization Changed from {0} to {1}", s_currentLocale, value), LogType.Log); | ||
s_currentLocale = value; | ||
await l10nDependencyProvider.Instance.Provider.LoadTranslationsAsync(); | ||
LocaleChangedEventArgs args = new LocaleChangedEventArgs(s_currentLocale); | ||
s_localeChanged.Invoke(this, args); | ||
} | ||
} | ||
private event EventHandler<ILocaleChangedEventArgs> s_localeChanged; | ||
|
||
public event EventHandler<ILocaleChangedEventArgs> LocaleChanged | ||
{ | ||
add | ||
{ | ||
s_localeChanged += value; | ||
} | ||
remove | ||
{ | ||
s_localeChanged -= value; | ||
} | ||
} | ||
|
||
[SerializeField] | ||
private ILocalizationDataHandler s_dataHandler; | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// Private Constructor to prevent creation of other Instances. | ||
/// </summary> | ||
private l10nManager() { } | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
l10n/Assets/Scripts/Localization/Observables/l10nManager.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
48 changes: 48 additions & 0 deletions
48
l10n/Assets/Scripts/Localization/Provider/LocalizationProvider.cs
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,48 @@ | ||
using l10n.Localization.sources; | ||
using l10n.Localization.translations; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using UnityEngine; | ||
|
||
namespace l10n.Localization.provider | ||
{ | ||
public class LocalizationProvider : ILocalizationProvider | ||
{ | ||
|
||
[SerializeField] | ||
private List<AbstractTranslation> s_translations; | ||
public IList<AbstractTranslation> Translations => s_translations ?? throw new Exception(); | ||
|
||
[SerializeField] | ||
private List<ILocalizationDataHandler> s_dataHandlers; | ||
public IList<ILocalizationDataHandler> DataHandlers => s_dataHandlers; | ||
|
||
public async Task LoadTranslationsAsync() | ||
{ | ||
//TODO | ||
|
||
} | ||
|
||
public void register(ILocalizationDataHandler handler) | ||
{ | ||
s_dataHandlers.Add(handler); | ||
} | ||
|
||
public void unregister(ILocalizationDataHandler handler) | ||
{ | ||
s_dataHandlers.Remove(handler); | ||
} | ||
|
||
public bool RegisterTranslation(string key, string locale, object value, object owner) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public AbstractTranslation Translate(string key) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
l10n/Assets/Scripts/Localization/Provider/LocalizationProvider.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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