22using System ;
33using System . Collections . Generic ;
44using System . IO ;
5+ using System . Linq ;
56using UnityEditor ;
67using UnityEngine ;
78using 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