| 1 | package i18n |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestProviderFailureCopyDoesNotClaimAutomaticRetry(t *testing.T) { |
| 10 | for locale, messages := range map[string]Messages{"en": English, "zh": Chinese, "zh-TW": ChineseTraditional} { |
| 11 | for _, copy := range []string{messages.ProviderErrAuthRejected, messages.ProviderErrRateLimited, messages.ProviderErrServer, messages.ProviderErrServerBusy} { |
| 12 | for _, retired := range []string{"Retried", "retried", "已退避重试", "已退避重試"} { |
| 13 | if strings.Contains(copy, retired) { |
| 14 | t.Errorf("%s claims a request was retried: %s", locale, copy) |
| 15 | } |
| 16 | } |
| 17 | } |
| 18 | for _, copy := range []string{messages.ProviderErrStreamInterruptedFmt, messages.ProviderErrDisconnectedFmt} { |
| 19 | if !strings.Contains(fmt.Sprintf(copy, "trace-123"), "trace-123") { |
| 20 | t.Errorf("%s lost the original diagnostic", locale) |
| 21 | } |
| 22 | if locale != "en" && !strings.Contains(copy, "模型") { |
| 23 | t.Errorf("%s stream failure is not localized: %s", locale, copy) |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 |