@@ -119,7 +119,7 @@ func (question *questionType) getDescContent() []byte {
119119 question .Title ,
120120 question .Difficulty .Str (),
121121 question .LeetCodeURL (),
122- question .TranslatedTitle ,
122+ question .translatedTitle () ,
123123 ))
124124 cts := filterContents (question .Content )
125125 // remove style
@@ -134,21 +134,32 @@ func (question *questionType) getDescContent() []byte {
134134 return buf .Bytes ()
135135}
136136
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+
137149func (question * questionType ) getNavigation () string {
138150 nav , pre , next := "\n %s\n %s\n %s\n " , "< Previous" , "Next >"
139151 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 )
151161 }
162+ break
152163 }
153164 }
154165 return fmt .Sprintf (nav , pre , strings .Repeat (" " , 16 ), next )
0 commit comments