Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit e08acc8

Browse files
committed
Move strings to localized resources
If we had done this before, we wouldn't have needed to move so much code around when moving the action bar...
1 parent 3a56b8f commit e08acc8

File tree

3 files changed

+180
-49
lines changed

3 files changed

+180
-49
lines changed

src/GitHub.Api/Localization.Designer.cs

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

src/GitHub.Api/Localization.resx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,43 @@
306306
<data name="GitVersionTooLow" xml:space="preserve">
307307
<value>The detected Git at {0} has version {1}, which is too low. The minimum Git version is {2}.</value>
308308
</data>
309+
<data name="BranchesTitle" xml:space="preserve">
310+
<value>Branches</value>
311+
</data>
312+
<data name="ChangesTitle" xml:space="preserve">
313+
<value>Changes</value>
314+
</data>
315+
<data name="DefaultRepoUrl" xml:space="preserve">
316+
<value>No remote configured</value>
317+
</data>
318+
<data name="FetchActionTitle" xml:space="preserve">
319+
<value>Fetch Changes</value>
320+
</data>
321+
<data name="FetchButtonText" xml:space="preserve">
322+
<value>Fetch</value>
323+
</data>
324+
<data name="FetchFailureDescription" xml:space="preserve">
325+
<value>Could not fetch changes</value>
326+
</data>
327+
<data name="HistoryTitle" xml:space="preserve">
328+
<value>History</value>
329+
</data>
330+
<data name="InitializeTitle" xml:space="preserve">
331+
<value>Initialize</value>
332+
</data>
333+
<data name="PublishButton" xml:space="preserve">
334+
<value>Publish</value>
335+
</data>
336+
<data name="SettingsTitle" xml:space="preserve">
337+
<value>Settings</value>
338+
</data>
339+
<data name="Window_RepoBranchTooltip" xml:space="preserve">
340+
<value>Active branch</value>
341+
</data>
342+
<data name="Window_RepoNoUrlTooltip" xml:space="preserve">
343+
<value>Add a remote in the Settings tab</value>
344+
</data>
345+
<data name="Window_RepoUrlTooltip" xml:space="preserve">
346+
<value>Url of the {0} remote</value>
347+
</data>
309348
</root>

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/Window.cs

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,6 @@ class Window : BaseWindow
1313
private const string Menu_Window_GitHub = "Window/GitHub";
1414
private const string Menu_Window_GitHub_Command_Line = "Window/GitHub Command Line";
1515
private const string BadNotificationDelayError = "A delay of {0} is shorter than the default delay and thus would get pre-empted.";
16-
private const string InitializeTitle = "Initialize";
17-
private const string HistoryTitle = "History";
18-
private const string ChangesTitle = "Changes";
19-
private const string BranchesTitle = "Branches";
20-
private const string SettingsTitle = "Settings";
21-
private const string DefaultRepoUrl = "No remote configured";
22-
private const string Window_RepoUrlTooltip = "Url of the {0} remote";
23-
private const string Window_RepoNoUrlTooltip = "Add a remote in the Settings tab";
24-
private const string Window_RepoBranchTooltip = "Active branch";
25-
private const string FetchActionTitle = "Fetch Changes";
26-
private const string FetchButtonText = "Fetch";
27-
private const string FetchFailureDescription = "Could not fetch changes";
28-
private const string PullButton = "Pull";
29-
private const string PullButtonCount = "Pull (<b>{0}</b>)";
30-
private const string PushButton = "Push";
31-
private const string PushButtonCount = "Push (<b>{0}</b>)";
32-
private const string PullConfirmTitle = "Pull Changes?";
33-
private const string PullConfirmDescription = "Would you like to pull changes from remote '{0}'?";
34-
private const string PullConfirmYes = "Pull";
35-
private const string PullConfirmCancel = "Cancel";
36-
private const string PushConfirmTitle = "Push Changes?";
37-
private const string PushConfirmDescription = "Would you like to push changes to remote '{0}'?";
38-
private const string PushConfirmYes = "Push";
39-
private const string PushConfirmCancel = "Cancel";
40-
private const string PublishButton = "Publish";
4116

4217
[NonSerialized] private bool currentBranchAndRemoteHasUpdate;
4318
[NonSerialized] private bool currentTrackingStatusHasUpdate;
@@ -295,7 +270,7 @@ private void MaybeUpdateData()
295270
}
296271

297272
string updatedRepoRemote = null;
298-
string updatedRepoUrl = DefaultRepoUrl;
273+
string updatedRepoUrl = Localization.DefaultRepoUrl;
299274

300275
var shouldUpdateContentFields = false;
301276

@@ -369,24 +344,24 @@ private void MaybeUpdateData()
369344
shouldUpdateContentFields = true;
370345
}
371346

372-
if (currentRemoteUrl != DefaultRepoUrl)
347+
if (currentRemoteUrl != Localization.DefaultRepoUrl)
373348
{
374-
currentRemoteUrl = DefaultRepoUrl;
349+
currentRemoteUrl = Localization.DefaultRepoUrl;
375350
shouldUpdateContentFields = true;
376351
}
377352
}
378353

379354
if (shouldUpdateContentFields || currentBranchContent == null || currentRemoteUrlContent == null)
380355
{
381-
currentBranchContent = new GUIContent(currentBranch, Window_RepoBranchTooltip);
356+
currentBranchContent = new GUIContent(currentBranch, Localization.Window_RepoBranchTooltip);
382357

383358
if (currentRemoteName != null)
384359
{
385-
currentRemoteUrlContent = new GUIContent(currentRemoteUrl, string.Format(Window_RepoUrlTooltip, currentRemoteName));
360+
currentRemoteUrlContent = new GUIContent(currentRemoteUrl, string.Format(Localization.Window_RepoUrlTooltip, currentRemoteName));
386361
}
387362
else
388363
{
389-
currentRemoteUrlContent = new GUIContent(currentRemoteUrl, Window_RepoNoUrlTooltip);
364+
currentRemoteUrlContent = new GUIContent(currentRemoteUrl, Localization.Window_RepoNoUrlTooltip);
390365
}
391366
}
392367
}
@@ -466,15 +441,15 @@ private void DoToolbarGUI()
466441
{
467442
if (HasRepository)
468443
{
469-
changeTab = TabButton(SubTab.Changes, ChangesTitle, changeTab);
470-
changeTab = TabButton(SubTab.History, HistoryTitle, changeTab);
471-
changeTab = TabButton(SubTab.Branches, BranchesTitle, changeTab);
444+
changeTab = TabButton(SubTab.Changes, Localization.ChangesTitle, changeTab);
445+
changeTab = TabButton(SubTab.History, Localization.HistoryTitle, changeTab);
446+
changeTab = TabButton(SubTab.Branches, Localization.BranchesTitle, changeTab);
472447
}
473448
else if (!HasRepository)
474449
{
475-
changeTab = TabButton(SubTab.InitProject, InitializeTitle, changeTab);
450+
changeTab = TabButton(SubTab.InitProject, Localization.InitializeTitle, changeTab);
476451
}
477-
changeTab = TabButton(SubTab.Settings, SettingsTitle, changeTab);
452+
changeTab = TabButton(SubTab.Settings, Localization.SettingsTitle, changeTab);
478453
}
479454

480455
if (EditorGUI.EndChangeCheck())
@@ -496,21 +471,21 @@ private void DoActionbarGUI()
496471
EditorGUI.BeginDisabledGroup(currentRemoteName == null);
497472
{
498473
// Fetch button
499-
var fetchClicked = GUILayout.Button(FetchButtonText, Styles.HistoryToolbarButtonStyle);
474+
var fetchClicked = GUILayout.Button(Localization.FetchButtonText, Styles.HistoryToolbarButtonStyle);
500475
if (fetchClicked)
501476
{
502477
Fetch();
503478
}
504479

505480
// Pull button
506-
var pullButtonText = statusBehind > 0 ? String.Format(PullButtonCount, statusBehind) : PullButton;
481+
var pullButtonText = statusBehind > 0 ? String.Format(Localization.PullButtonCount, statusBehind) : Localization.PullButton;
507482
var pullClicked = GUILayout.Button(pullButtonText, Styles.HistoryToolbarButtonStyle);
508483

509484
if (pullClicked &&
510-
EditorUtility.DisplayDialog(PullConfirmTitle,
511-
String.Format(PullConfirmDescription, currentRemoteName),
512-
PullConfirmYes,
513-
PullConfirmCancel)
485+
EditorUtility.DisplayDialog(Localization.PullConfirmTitle,
486+
String.Format(Localization.PullConfirmDescription, currentRemoteName),
487+
Localization.PullConfirmYes,
488+
Localization.PullConfirmCancel)
514489
)
515490
{
516491
Pull();
@@ -521,14 +496,14 @@ private void DoActionbarGUI()
521496
// Push button
522497
EditorGUI.BeginDisabledGroup(currentRemoteName == null || statusBehind != 0);
523498
{
524-
var pushButtonText = statusAhead > 0 ? String.Format(PushButtonCount, statusAhead) : PushButton;
499+
var pushButtonText = statusAhead > 0 ? String.Format(Localization.PushButtonCount, statusAhead) : Localization.PushButton;
525500
var pushClicked = GUILayout.Button(pushButtonText, Styles.HistoryToolbarButtonStyle);
526501

527502
if (pushClicked &&
528-
EditorUtility.DisplayDialog(PushConfirmTitle,
529-
String.Format(PushConfirmDescription, currentRemoteName),
530-
PushConfirmYes,
531-
PushConfirmCancel)
503+
EditorUtility.DisplayDialog(Localization.PushConfirmTitle,
504+
String.Format(Localization.PushConfirmDescription, currentRemoteName),
505+
Localization.PushConfirmYes,
506+
Localization.PushConfirmCancel)
532507
)
533508
{
534509
Push();
@@ -539,7 +514,7 @@ private void DoActionbarGUI()
539514
else
540515
{
541516
// Publishing a repo
542-
var publishedClicked = GUILayout.Button(PublishButton, Styles.HistoryToolbarButtonStyle);
517+
var publishedClicked = GUILayout.Button(Localization.PublishButton, Styles.HistoryToolbarButtonStyle);
543518
if (publishedClicked)
544519
{
545520
PopupWindow.OpenWindow(PopupWindow.PopupViewType.PublishView);
@@ -616,7 +591,7 @@ private void Fetch()
616591
{
617592
TaskManager.Run(EntryPoint.ApplicationManager.UsageTracker.IncrementHistoryViewToolbarFetch);
618593

619-
EditorUtility.DisplayDialog(FetchActionTitle, FetchFailureDescription,
594+
EditorUtility.DisplayDialog(Localization.FetchActionTitle, Localization.FetchFailureDescription,
620595
Localization.Ok);
621596
}
622597
})

0 commit comments

Comments
 (0)