@@ -2,14 +2,14 @@ package gotext
2
2
3
3
import (
4
4
"bufio"
5
- "fmt"
6
- "github.com/mattn/kinako/vm"
7
5
"io/ioutil"
8
6
"net/textproto"
9
7
"os"
10
8
"strconv"
11
9
"strings"
12
10
"sync"
11
+
12
+ "github.com/mattn/kinako/vm"
13
13
)
14
14
15
15
type translation struct {
@@ -427,12 +427,12 @@ func (po *Po) Get(str string, vars ...interface{}) string {
427
427
428
428
if po .translations != nil {
429
429
if _ , ok := po .translations [str ]; ok {
430
- return po . printf (po .translations [str ].get (), vars ... )
430
+ return printf (po .translations [str ].get (), vars ... )
431
431
}
432
432
}
433
433
434
434
// Return the same we received by default
435
- return po . printf (str , vars ... )
435
+ return printf (str , vars ... )
436
436
}
437
437
438
438
// GetN retrieves the (N)th plural form of translation for the given string.
@@ -444,14 +444,14 @@ func (po *Po) GetN(str, plural string, n int, vars ...interface{}) string {
444
444
445
445
if po .translations != nil {
446
446
if _ , ok := po .translations [str ]; ok {
447
- return po . printf (po .translations [str ].getN (po .pluralForm (n )), vars ... )
447
+ return printf (po .translations [str ].getN (po .pluralForm (n )), vars ... )
448
448
}
449
449
}
450
450
451
451
if n == 1 {
452
- return po . printf (str , vars ... )
452
+ return printf (str , vars ... )
453
453
}
454
- return po . printf (plural , vars ... )
454
+ return printf (plural , vars ... )
455
455
}
456
456
457
457
// GetC retrieves the corresponding translation for a given string in the given context.
@@ -465,14 +465,14 @@ func (po *Po) GetC(str, ctx string, vars ...interface{}) string {
465
465
if _ , ok := po .contexts [ctx ]; ok {
466
466
if po .contexts [ctx ] != nil {
467
467
if _ , ok := po.contexts [ctx ][str ]; ok {
468
- return po . printf (po.contexts [ctx ][str ].get (), vars ... )
468
+ return printf (po.contexts [ctx ][str ].get (), vars ... )
469
469
}
470
470
}
471
471
}
472
472
}
473
473
474
474
// Return the string we received by default
475
- return po . printf (str , vars ... )
475
+ return printf (str , vars ... )
476
476
}
477
477
478
478
// GetNC retrieves the (N)th plural form of translation for the given string in the given context.
@@ -486,23 +486,14 @@ func (po *Po) GetNC(str, plural string, n int, ctx string, vars ...interface{})
486
486
if _ , ok := po .contexts [ctx ]; ok {
487
487
if po .contexts [ctx ] != nil {
488
488
if _ , ok := po.contexts [ctx ][str ]; ok {
489
- return po . printf (po.contexts [ctx ][str ].getN (po .pluralForm (n )), vars ... )
489
+ return printf (po.contexts [ctx ][str ].getN (po .pluralForm (n )), vars ... )
490
490
}
491
491
}
492
492
}
493
493
}
494
494
495
495
if n == 1 {
496
- return po . printf (str , vars ... )
496
+ return printf (str , vars ... )
497
497
}
498
- return po .printf (plural , vars ... )
499
- }
500
-
501
- // printf applies text formatting only when needed to parse variables.
502
- func (po * Po ) printf (str string , vars ... interface {}) string {
503
- if len (vars ) > 0 {
504
- return fmt .Sprintf (str , vars ... )
505
- }
506
-
507
- return str
498
+ return printf (plural , vars ... )
508
499
}
0 commit comments