Skip to content

Commit b8a43ad

Browse files
committed
feat: re working change language and window
1 parent 9a0527c commit b8a43ad

25 files changed

Lines changed: 216 additions & 158 deletions

Assets/Code/Infrastructure/BootstrapInstaller.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Code.Infrastructure.Services.PersistenceProgress;
33
using Code.Infrastructure.Services.SaveLoad;
44
using Code.Infrastructure.Services.StaticData;
5+
using Code.Localization.Code.Services.LocalizeLanguageService;
56
using Services.PersistenceProgress;
67
using UnityEngine.SceneManagement;
78
using Zenject;
@@ -18,10 +19,16 @@ public override void InstallBindings()
1819

1920
BindFactory();
2021
BindSaveLoad();
22+
BindLocalizeLanguage();
2123
BindProgressData();
2224
BindStaticData();
2325
}
2426

27+
private void BindLocalizeLanguage()
28+
{
29+
Container.BindInterfacesTo<LocalizeLanguageService>().AsSingle();
30+
}
31+
2532
private void BindFactory()
2633
{
2734
Container.BindInterfacesTo<UIFactory>().AsSingle();

Assets/Code/Localization/Scripts/Locale.cs renamed to Assets/Code/Localization/Code/Locale.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
using System.Collections.Generic;
22
using UnityEngine;
33

4-
namespace Localization
4+
namespace Code.Localization.Code
55
{
66
public static class Locale
77
{
88
private const string STR_LOCALIZATION_KEY = "locale";
99
private const string STR_LOCALIZATION_PREFIX = "localization/";
1010

1111
private static string _currentLanguage;
12-
12+
private static TextAsset _currentLocalizationText;
13+
1314
public static bool currentLanguageHasBeenSet = false;
1415
public static Dictionary<string, string> currentLanguageStrings = new();
15-
16-
private static TextAsset _currentLocalizationText;
17-
16+
1817
public static string CurrentLanguage
1918
{
2019
get { return _currentLanguage; }
File renamed without changes.

Assets/Code/Localization/Scripts/Localize.cs renamed to Assets/Code/Localization/Code/Localize.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using UnityEngine;
21
using TMPro;
2+
using UnityEngine;
33

4-
namespace Localization
4+
namespace Code.Localization.Code
55
{
66
[RequireComponent(typeof(TMP_Text))]
7-
public class Localize : LocalizBase
7+
public class Localize : LocalizeBase
88
{
99
private TMP_Text _text;
1010

@@ -21,7 +21,6 @@ public override void UpdateLocale()
2121
if (!System.String.IsNullOrEmpty(localizationKey) &&
2222
Locale.currentLanguageStrings.ContainsKey(localizationKey))
2323
_text.text = Locale.currentLanguageStrings[localizationKey].Replace(@"\n", "" + '\n');
24-
;
2524
}
2625
}
2726
}
File renamed without changes.

Assets/Code/Localization/Scripts/LocalizeBase.cs renamed to Assets/Code/Localization/Code/LocalizeBase.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using UnityEngine;
22

3-
namespace Localization
3+
namespace Code.Localization.Code
44
{
5-
public abstract class LocalizBase : MonoBehaviour
5+
public abstract class LocalizeBase : MonoBehaviour
66
{
77
public string localizationKey;
88

@@ -23,15 +23,15 @@ public static string GetLocalizedString(string key)
2323
{
2424
if (Locale.currentLanguageStrings.ContainsKey(key))
2525
return Locale.currentLanguageStrings[key];
26-
else
27-
return string.Empty;
26+
27+
return string.Empty;
2828
}
2929

3030
public static void SetCurrentLanguage(SystemLanguage language)
3131
{
3232
Locale.CurrentLanguage = language.ToString();
3333
Locale.PlayerLanguage = language;
34-
Localize[] allTexts = GameObject.FindObjectsOfType<Localize>();
34+
Localize[] allTexts = FindObjectsOfType<Localize>();
3535
for (int i = 0; i < allTexts.Length; i++)
3636
allTexts[i].UpdateLocale();
3737
}
File renamed without changes.

Assets/Code/Localization/Intro/Scripts.meta renamed to Assets/Code/Localization/Code/Services.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Code/Localization/Code/Services/LocalizeLanguageService.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)