Skip to content

Commit 33dd464

Browse files
committed
fix: clean code
1 parent 1eee1ff commit 33dd464

5 files changed

Lines changed: 21 additions & 26 deletions

File tree

Assets/Code/Infrastructure/Services/GameStater/GameStarter.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,11 @@ private void InitLanguage()
5353

5454
private PlayerData LoadProgress()
5555
{
56-
Debug.Log("LoadProgress");
57-
5856
return _saveLoadService.Load();
5957
}
6058

6159
private PlayerData SetUpBaseProgress()
6260
{
63-
Debug.Log("InitializeProgress");
6461
var progress = new PlayerData();
6562
_progressService.PlayerData = progress;
6663
return progress;

Assets/Code/Localization/Code/Locale.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public static SystemLanguage PlayerLanguage
6666
{
6767
PlayerPrefs.SetInt(STR_LOCALIZATION_KEY, (int)value);
6868
PlayerPrefs.Save();
69-
Debug.Log("Locale: Player language set to " + value);
7069
}
7170
}
7271
}

Assets/Code/Localization/Code/Services/LocalizeLanguageService/LocalizeLanguageService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public class LocalizeLanguageService : ILocalizeLanguageService
1111

1212
public void InitLanguage()
1313
{
14-
Debug.Log("InitLanguage =" + GetCurrentLanguage());
1514
SetLanguage(GetCurrentLanguage().ToString());
1615
}
1716

@@ -25,6 +24,7 @@ public void SetLanguage(string languageName)
2524
{
2625
Locale.CurrentLanguage = languageName;
2726
Locale.PlayerLanguage = LanguageNameToSystemLanguage(languageName);
27+
2828
LocalizeBase[] allTexts = Object.FindObjectsOfType<LocalizeBase>();
2929
foreach (var t in allTexts)
3030
t.UpdateLocale();
@@ -36,7 +36,9 @@ private SystemLanguage LanguageNameToSystemLanguage(string name)
3636
{
3737
if (System.Enum.TryParse<SystemLanguage>(name, true, out var lang))
3838
return lang;
39-
Debug.LogWarning($"⚠️ Unknown language '{name}', fallback to English.");
39+
40+
Debug.LogWarning($"⚠Unknown language '{name}', fallback to English.");
41+
4042
return SystemLanguage.English;
4143
}
4244
}

Assets/Code/Localization/Code/TMP_Localizer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using TMPro;
22
using UnityEngine;
33
using Code.Localization.Code.Services.LocalizeLanguageService;
4-
using Zenject;
54

65
namespace Code.Localization.Code
76
{

Assets/Code/Localization/Editor/LocalizationEditorWindow.cs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.IO;
5+
using System.Linq;
56
using UnityEditor;
67
using UnityEngine;
78
using Sirenix.OdinInspector;
@@ -18,7 +19,7 @@ public class LocalizationEditorWindow : OdinEditorWindow
1819
[MenuItem("Tools/Localization Editor 🈺")]
1920
private static void OpenWindow()
2021
{
21-
var window = GetWindow<LocalizationEditorWindow>();
22+
LocalizationEditorWindow window = GetWindow<LocalizationEditorWindow>();
2223
window.titleContent = new GUIContent("Localization Editor");
2324
window.minSize = new Vector2(600, 800);
2425
window.Show();
@@ -48,14 +49,11 @@ private static void OpenWindow()
4849
[Button("Save Current Language", ButtonSizes.Large), GUIColor(0.6f, 1f, 0.6f)]
4950
private void Save()
5051
{
51-
if (string.IsNullOrEmpty(_selectedLanguage)) return;
52+
if (string.IsNullOrEmpty(_selectedLanguage))
53+
return;
5254

5355
string path = Path.Combine(LocalizationFolder, _selectedLanguage + ".txt");
54-
List<string> lines = new();
55-
foreach (var entry in _entries)
56-
{
57-
lines.Add($"{entry.Key}={entry.Value.Replace("\n", "\\n")}");
58-
}
56+
List<string> lines = _entries.Select(entry => $"{entry.Key}={entry.Value.Replace("\n", "\\n")}").ToList();
5957

6058
File.WriteAllLines(path, lines);
6159
AssetDatabase.Refresh();
@@ -176,28 +174,28 @@ private void FindTMPLocalizersInAssets()
176174
[Button("Save Changes To Assets", ButtonSizes.Large), GUIColor(0.6f, 1f, 0.6f)]
177175
private void ApplyLocalizationKeyChangesToAssets()
178176
{
179-
Debug.Log("=== 🔁 Start Applying LocalizationKey Changes ===");
177+
Debug.Log("Start Applying LocalizationKey Changes");
180178

181179
int updatedCount = 0;
182-
var pathsToLog = new HashSet<string>();
180+
HashSet<string> pathsToLog = new HashSet<string>();
183181

184-
foreach (var entry in _localizersInAssets)
182+
foreach (TMPAssetEntry entry in _localizersInAssets)
185183
{
186184
if (string.IsNullOrEmpty(entry.AssetPath) || string.IsNullOrEmpty(entry.GameObjectName))
187185
{
188-
Debug.LogWarning("⚠️ Missing path or object name, skipping.");
186+
Debug.LogWarning("Missing path or object name, skipping.");
189187
continue;
190188
}
191189

192-
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(entry.AssetPath);
190+
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(entry.AssetPath);
193191
if (prefab == null)
194192
{
195-
Debug.LogWarning($"⚠️ Failed to load prefab at path: {entry.AssetPath}");
193+
Debug.LogWarning($"Failed to load prefab at path: {entry.AssetPath}");
196194
continue;
197195
}
198196

199-
var localizers = prefab.GetComponentsInChildren<LocalizeBase>(true);
200-
foreach (var localizer in localizers)
197+
LocalizeBase[] localizers = prefab.GetComponentsInChildren<LocalizeBase>(true);
198+
foreach (LocalizeBase localizer in localizers)
201199
{
202200
if (localizer.gameObject.name != entry.GameObjectName) continue;
203201

@@ -211,15 +209,15 @@ private void ApplyLocalizationKeyChangesToAssets()
211209
EditorUtility.SetDirty(localizer);
212210
updatedCount++;
213211

214-
Debug.Log($"📝 Updated '{entry.GameObjectName}' in '{entry.AssetPath}': '{oldKey}' ➜ '{newKey}'");
212+
Debug.Log($"Updated '{entry.GameObjectName}' in '{entry.AssetPath}': '{oldKey}' ➜ '{newKey}'");
215213
}
216214
else
217215
{
218-
Debug.Log($"No change needed for '{entry.GameObjectName}' (key already '{oldKey}')");
216+
Debug.Log($"No change needed for '{entry.GameObjectName}' (key already '{oldKey}')");
219217
}
220218

221219
pathsToLog.Add(entry.AssetPath);
222-
break; // нашли нужный объект — идём дальше
220+
break;
223221
}
224222

225223
EditorUtility.SetDirty(prefab);
@@ -335,7 +333,7 @@ private IEnumerable<string> GetAvailableLanguages()
335333

336334
private IEnumerable<SystemLanguage> GetNewLanguages()
337335
{
338-
var existing = new HashSet<string>(GetAvailableLanguages(), StringComparer.OrdinalIgnoreCase);
336+
HashSet<string> existing = new HashSet<string>(GetAvailableLanguages(), StringComparer.OrdinalIgnoreCase);
339337
foreach (SystemLanguage lang in Enum.GetValues(typeof(SystemLanguage)))
340338
{
341339
if (!existing.Contains(lang.ToString()))

0 commit comments

Comments
 (0)