@@ -13,6 +13,7 @@ import PropTypes from "prop-types";
1313import Overridable from "react-overridable" ;
1414import { RANGE_MODES , VALUE_TYPES } from "./utils" ;
1515import { AppContext } from "../ReactSearchKit" ;
16+ import { i18next } from "@translations/i18next" ;
1617
1718// Masked input formatters: strip non-digits and auto-insert separators.
1819// As the user types, digits are reformatted on each keystroke:
@@ -31,7 +32,7 @@ const FORMAT_FNS = {
3132} ;
3233
3334const DEFAULT_HELP_TEXTS = {
34- [ VALUE_TYPES . DATE ] : "e.g. 2025 or 2025-03-15" ,
35+ [ VALUE_TYPES . DATE ] : i18next . t ( "e.g. 2025 or 2025-03-15" ) ,
3536 [ VALUE_TYPES . INT ] : null ,
3637} ;
3738
@@ -180,34 +181,38 @@ class RangeCustomFilter extends React.Component {
180181 const isDate = valueType !== VALUE_TYPES . INT ;
181182
182183 if ( ! fromValue && ! toValue ) {
183- return this . setError ( "Enter at least one value" ) ;
184+ return this . setError ( i18next . t ( "Enter at least one value" ) ) ;
184185 }
185186
186187 if ( fromValue ) {
187188 if ( isDate && fromValue . length < 4 ) {
188- return this . setError ( "Year must be 4 digits" ) ;
189+ return this . setError ( i18next . t ( "Year must be 4 digits" ) ) ;
189190 }
190191 const from = this . parseValue ( fromValue , true ) ;
191192 if ( from === null ) {
192- return this . setError ( isDate ? "Invalid date" : "Invalid number" ) ;
193+ return this . setError (
194+ isDate ? i18next . t ( "Invalid date" ) : i18next . t ( "Invalid number" )
195+ ) ;
193196 }
194197 }
195198
196199 if ( toValue ) {
197200 if ( isDate && toValue . length < 4 ) {
198- return this . setError ( "Year must be 4 digits" ) ;
201+ return this . setError ( i18next . t ( "Year must be 4 digits" ) ) ;
199202 }
200203 const to = this . parseValue ( toValue , false ) ;
201204 if ( to === null ) {
202- return this . setError ( isDate ? "Invalid date" : "Invalid number" ) ;
205+ return this . setError (
206+ isDate ? i18next . t ( "Invalid date" ) : i18next . t ( "Invalid number" )
207+ ) ;
203208 }
204209 }
205210
206211 if ( fromValue && toValue ) {
207212 const from = this . parseValue ( fromValue , true ) ;
208213 const to = this . parseValue ( toValue , false ) ;
209214 if ( from > to ) {
210- return this . setError ( "Start must be before end" ) ;
215+ return this . setError ( i18next . t ( "Start must be before end" ) ) ;
211216 }
212217 }
213218
@@ -363,13 +368,13 @@ RangeCustomFilter.defaultProps = {
363368 activeMode : null ,
364369 activeFilter : null ,
365370 overridableId : "" ,
366- dateRangeToLabel : "to" ,
371+ dateRangeToLabel : i18next . t ( "to" ) ,
367372 valueType : VALUE_TYPES . DATE ,
368373 helpText : undefined ,
369374 fromAriaLabel : "From" ,
370375 toAriaLabel : "To" ,
371- applyAriaLabel : "Apply custom range" ,
372- customRangeAriaLabel : "Custom range" ,
376+ applyAriaLabel : i18next . t ( "Apply custom range" ) ,
377+ customRangeAriaLabel : i18next . t ( "Custom range" ) ,
373378} ;
374379
375380RangeCustomFilter . contextType = AppContext ;
0 commit comments