]> asedeno.scripts.mit.edu Git - git.git/blobdiff - lib/index.tcl
git-gui: add some strings to translation
[git.git] / lib / index.tcl
index 42742850eef627262844d2414a593a6e8952d08a..47255261d293432b2094385de89387d401d20a66 100644 (file)
@@ -2,7 +2,7 @@
 # Copyright (C) 2006, 2007 Shawn Pearce
 
 proc update_indexinfo {msg pathList after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
 
        if {![lock_index update]} return
 
@@ -12,12 +12,13 @@ proc update_indexinfo {msg pathList after} {
        set batch [expr {int($totalCnt * .01) + 1}]
        if {$batch > 25} {set batch 25}
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                0.0]
-       set fd [open "| git update-index -z --index-info" w]
+       set fd [git_write update-index -z --index-info]
        fconfigure $fd \
                -blocking 0 \
                -buffering full \
@@ -36,7 +37,7 @@ proc update_indexinfo {msg pathList after} {
 }
 
 proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
        global file_states current_diff_path
 
        if {$update_index_cp >= $totalCnt} {
@@ -67,15 +68,16 @@ proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
                display_file $path $new
        }
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                [expr {100.0 * $update_index_cp / $totalCnt}]]
 }
 
 proc update_index {msg pathList after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
 
        if {![lock_index update]} return
 
@@ -85,12 +87,13 @@ proc update_index {msg pathList after} {
        set batch [expr {int($totalCnt * .01) + 1}]
        if {$batch > 25} {set batch 25}
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                0.0]
-       set fd [open "| git update-index --add --remove -z --stdin" w]
+       set fd [git_write update-index --add --remove -z --stdin]
        fconfigure $fd \
                -blocking 0 \
                -buffering full \
@@ -109,7 +112,7 @@ proc update_index {msg pathList after} {
 }
 
 proc write_update_index {fd pathList totalCnt batch msg after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
        global file_states current_diff_path
 
        if {$update_index_cp >= $totalCnt} {
@@ -144,15 +147,16 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
                display_file $path $new
        }
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                [expr {100.0 * $update_index_cp / $totalCnt}]]
 }
 
 proc checkout_index {msg pathList after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
 
        if {![lock_index update]} return
 
@@ -162,18 +166,19 @@ proc checkout_index {msg pathList after} {
        set batch [expr {int($totalCnt * .01) + 1}]
        if {$batch > 25} {set batch 25}
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                0.0]
-       set cmd [list git checkout-index]
-       lappend cmd --index
-       lappend cmd --quiet
-       lappend cmd --force
-       lappend cmd -z
-       lappend cmd --stdin
-       set fd [open "| $cmd " w]
+       set fd [git_write checkout-index \
+               --index \
+               --quiet \
+               --force \
+               -z \
+               --stdin \
+               ]
        fconfigure $fd \
                -blocking 0 \
                -buffering full \
@@ -192,7 +197,7 @@ proc checkout_index {msg pathList after} {
 }
 
 proc write_checkout_index {fd pathList totalCnt batch msg after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
        global file_states current_diff_path
 
        if {$update_index_cp >= $totalCnt} {
@@ -217,8 +222,9 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
                }
        }
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                [expr {100.0 * $update_index_cp / $totalCnt}]]
@@ -249,7 +255,7 @@ proc unstage_helper {txt paths} {
                update_indexinfo \
                        $txt \
                        $pathList \
-                       [concat $after {set ui_status_value {Ready.}}]
+                       [concat $after [list ui_ready]]
        }
 }
 
@@ -262,7 +268,7 @@ proc do_unstage_selection {} {
                        [array names selected_paths]
        } elseif {$current_diff_path ne {}} {
                unstage_helper \
-                       "Unstaging [short_path $current_diff_path] from commit" \
+                       [mc "Unstaging %s from commit" [short_path $current_diff_path]] \
                        [list $current_diff_path]
        }
 }
@@ -293,7 +299,7 @@ proc add_helper {txt paths} {
                update_index \
                        $txt \
                        $pathList \
-                       [concat $after {set ui_status_value {Ready to commit.}}]
+                       [concat $after {ui_status {Ready to commit.}}]
        }
 }
 
@@ -306,7 +312,7 @@ proc do_add_selection {} {
                        [array names selected_paths]
        } elseif {$current_diff_path ne {}} {
                add_helper \
-                       "Adding [short_path $current_diff_path]" \
+                       [mc "Adding %s" [short_path $current_diff_path]] \
                        [list $current_diff_path]
        }
 }
@@ -345,32 +351,41 @@ proc revert_helper {txt paths} {
                }
        }
 
+
+       # Split question between singular and plural cases, because
+       # such distinction is needed in some languages. Previously, the
+       # code used "Revert changes in" for both, but that can't work
+       # in languages where 'in' must be combined with word from
+       # rest of string (in diffrent way for both cases of course).
+       #
+       # FIXME: Unfortunately, even that isn't enough in some languages
+       # as they have quite complex plural-form rules. Unfortunately,
+       # msgcat doesn't seem to support that kind of string translation.
+       #
        set n [llength $pathList]
        if {$n == 0} {
                unlock_index
                return
        } elseif {$n == 1} {
-               set s "[short_path [lindex $pathList]]"
+               set query [mc "Revert changes in file %s?" [short_path [lindex $pathList]]]
        } else {
-               set s "these $n files"
+               set query [mc "Revert changes in these %i files?" $n]
        }
 
        set reply [tk_dialog \
                .confirm_revert \
                "[appname] ([reponame])" \
-               "Revert changes in $s?
-
-Any unadded changes will be permanently lost by the revert." \
+               [mc "Any unstaged changes will be permanently lost by the revert."] \
                question \
                1 \
-               {Do Nothing} \
-               {Revert Changes} \
+               [mc "Do Nothing"] \
+               [mc "Revert Changes"] \
                ]
        if {$reply == 1} {
                checkout_index \
                        $txt \
                        $pathList \
-                       [concat $after {set ui_status_value {Ready.}}]
+                       [concat $after [list ui_ready]]
        } else {
                unlock_index
        }