@@ -12,13 +12,21 @@ export default function useAutoTranslate() {
1212 return entity [ `${ field } _detected_language` ]
1313 }
1414
15+ const useOriginalValue = ( entity , field ) => {
16+ const _entity = unref ( entity )
17+ const _field = unref ( field )
18+ let res = ! isAutoTranslateActivated . value
19+ if ( ! res && _entity && _field ) res = _entity [ `${ _field } _detected_language` ] === locale . value
20+ return res
21+ }
22+
1523 const getTranslatableField = ( entity : any , field : string , defaultValue : any = '' ) =>
1624 computed ( ( ) => {
1725 const _entity = unref ( entity )
1826 const _field = unref ( field )
1927 const _defaultValue = unref ( defaultValue )
2028 if ( ! _entity || ! _field ) return _defaultValue
21- if ( ! isAutoTranslateActivated . value ) return _entity [ _field ] || _defaultValue
29+ if ( useOriginalValue ( _entity , _field ) ) return _entity [ _field ] || _defaultValue
2230 return _entity [ `${ _field } _${ locale . value } ` ] || _entity [ _field ] || _defaultValue
2331 } )
2432
@@ -30,7 +38,7 @@ export default function useAutoTranslate() {
3038 for ( const field of fields ) {
3139 const _field = unref ( field )
3240 if ( ! _entity || ! _field ) continue
33- else if ( ! isAutoTranslateActivated . value ) res [ _field ] = _entity [ _field ] || _defaultValue
41+ else if ( useOriginalValue ( _entity , _field ) ) res [ _field ] = _entity [ _field ] || _defaultValue
3442 else res [ _field ] = _entity [ `${ _field } _${ locale . value } ` ] || _entity [ _field ] || _defaultValue
3543 }
3644 return res
0 commit comments