File tree Expand file tree Collapse file tree 1 file changed +27
-5
lines changed Expand file tree Collapse file tree 1 file changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -131,22 +131,44 @@ const template = {
131
131
} ,
132
132
}
133
133
134
+ function updateText ( options , path ) {
135
+ [ 'previousText' , 'nextText' ] . forEach ( key => {
136
+ const text = options [ key ]
137
+
138
+ if ( typeof text === 'string' ) {
139
+ options [ key ] = text
140
+ } else {
141
+ Object . keys ( text ) . some ( local => {
142
+ const isMatch = path . indexOf ( local ) > - 1
143
+
144
+ options [ key ] = isMatch ? text [ local ] : text
145
+
146
+ return isMatch
147
+ } ) ;
148
+ }
149
+ } )
150
+ }
151
+
134
152
/**
135
153
* installation
136
154
*/
137
155
export function install ( hook , vm ) {
138
- let options = Object . assign (
156
+ const options = Object . assign (
139
157
{ } ,
140
158
DEFAULT_OPTIONS ( vm . config ) ,
141
159
vm . config . pagination || { }
142
160
)
143
161
144
162
function render ( ) {
145
163
const container = query ( `.${ CONTAINER_CLASSNAME } ` )
146
- if ( ! container ) {
147
- return
148
- }
149
- container . innerHTML = template . inner ( pagination ( vm , options ) , options )
164
+
165
+ if ( ! container ) return
166
+
167
+ const i18n = JSON . parse ( JSON . stringify ( options ) )
168
+
169
+ updateText ( i18n , vm . route . path ) ;
170
+
171
+ container . innerHTML = template . inner ( pagination ( vm , i18n ) , i18n )
150
172
}
151
173
152
174
hook . afterEach ( ( html ) => html + template . container ( ) )
You can’t perform that action at this time.
0 commit comments