File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
assets/javascripts/wizard/lib Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -13,20 +13,32 @@ const getThemeId = () => {
1313 }
1414} ;
1515
16+ const getThemeKey = ( key ) => {
17+ const themeId = getThemeId ( ) ;
18+ return `theme_translations.${ themeId } .${ key } ` ;
19+ } ;
20+
1621const translationExists = ( key ) => {
1722 return (
1823 I18n . findTranslation ( key , { locale : I18n . locale } ) ||
1924 I18n . findTranslation ( key , { locale : I18n . defaultLocale } )
2025 ) ;
2126} ;
2227
28+ const translatedText = ( key , value ) => {
29+ const themeKey = getThemeKey ( key ) ;
30+ return translationExists ( themeKey ) ? I18n . t ( themeKey ) : value ;
31+ } ;
32+
33+ export { translatedText } ;
34+
2335const WizardI18n = ( key , params = { } ) => {
2436 const themeId = getThemeId ( ) ;
2537 if ( ! themeId ) {
2638 return I18n . t ( key , params ) ;
2739 }
2840
29- const themeKey = `theme_translations. ${ themeId } . ${ key } ` ;
41+ let themeKey = getThemeKey ( key ) ;
3042
3143 if ( translationExists ( themeKey ) ) {
3244 return I18n . t ( themeKey , params ) ;
You can’t perform that action at this time.
0 commit comments