Commits

Anonymous committed a813988

git-gui: Refactor current branch menu items to make i18n easier

The i18n team has also identified a rather ugly block of code in
git-gui that is used to make a pair of Repository menu items show
the current branch name. This code is difficult to convert to use
[mc ...] to lookup the translation, so I'm refactoring it into a
procedure.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Comments (0)

Files changed (1)

 .mbar.repository add command \
 	-label {Browse Current Branch's Files} \
 	-command {browser::new $current_branch}
-trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch's Files\" ;#"
+set ui_browse_current [.mbar.repository index last]
 .mbar.repository add command \
 	-label {Browse Branch Files...} \
 	-command browser_open::dialog
 .mbar.repository add command \
 	-label {Visualize Current Branch's History} \
 	-command {do_gitk $current_branch}
-trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch's History\" ;#"
+set ui_visualize_current [.mbar.repository index last]
 .mbar.repository add command \
 	-label {Visualize All Branch History} \
 	-command {do_gitk --all}
 .mbar.repository add separator
 
+proc current_branch_write {args} {
+	global current_branch
+	.mbar.repository entryconf $::ui_browse_current \
+		-label "Browse $current_branch's Files"
+	.mbar.repository entryconf $::ui_visualize_current \
+		-label "Visualize $current_branch's History"
+}
+trace add variable current_branch write current_branch_write
+
 if {[is_enabled multicommit]} {
 	.mbar.repository add command -label {Database Statistics} \
 		-command do_stats
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.