@@ -119,7 +119,7 @@ func (question *questionType) getDescContent() []byte {
119
119
question .Title ,
120
120
question .Difficulty .Str (),
121
121
question .LeetCodeURL (),
122
- question .TranslatedTitle ,
122
+ question .translatedTitle () ,
123
123
))
124
124
cts := filterContents (question .Content )
125
125
// remove style
@@ -134,21 +134,32 @@ func (question *questionType) getDescContent() []byte {
134
134
return buf .Bytes ()
135
135
}
136
136
137
+ func (question * questionType ) questionID () int {
138
+ id , _ := strconv .Atoi (question .QuestionID )
139
+ return id
140
+ }
141
+
142
+ func (question * questionType ) translatedTitle () string {
143
+ if question .TranslatedTitle == "" {
144
+ question .TranslatedTitle = translationSet [question .questionID ()]
145
+ }
146
+ return question .TranslatedTitle
147
+ }
148
+
137
149
func (question * questionType ) getNavigation () string {
138
150
nav , pre , next := "\n %s\n %s\n %s\n " , "< Previous" , "Next >"
139
151
problems := ProblemsAll ().StatStatusPairs
140
- if id , err := strconv .Atoi (question .QuestionID ); err == nil {
141
- format := `[%s](https://github.com/openset/leetcode/tree/master/problems/%s "%s")`
142
- for i , problem := range problems {
143
- if problem .Stat .QuestionID == id {
144
- if i < len (problems )- 1 {
145
- pre = fmt .Sprintf (format , pre , problems [i + 1 ].Stat .QuestionTitleSlug , problems [i + 1 ].Stat .QuestionTitle )
146
- }
147
- if i > 0 {
148
- next = fmt .Sprintf (format , next , problems [i - 1 ].Stat .QuestionTitleSlug , problems [i - 1 ].Stat .QuestionTitle )
149
- }
150
- break
152
+ id := question .questionID ()
153
+ format := `[%s](https://github.com/openset/leetcode/tree/master/problems/%s "%s")`
154
+ for i , problem := range problems {
155
+ if problem .Stat .QuestionID == id {
156
+ if i < len (problems )- 1 {
157
+ pre = fmt .Sprintf (format , pre , problems [i + 1 ].Stat .QuestionTitleSlug , problems [i + 1 ].Stat .QuestionTitle )
158
+ }
159
+ if i > 0 {
160
+ next = fmt .Sprintf (format , next , problems [i - 1 ].Stat .QuestionTitleSlug , problems [i - 1 ].Stat .QuestionTitle )
151
161
}
162
+ break
152
163
}
153
164
}
154
165
return fmt .Sprintf (nav , pre , strings .Repeat (" " , 16 ), next )
0 commit comments