Make auto inline translation as a setting, turned off by default
This commit is contained in:
parent
d8b385a742
commit
32a853ecc0
|
@ -59,6 +59,9 @@
|
|||
#settings-container div {
|
||||
vertical-align: middle;
|
||||
}
|
||||
#settings-container section > ul > li .sub-section hr {
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
#settings-container section select {
|
||||
padding: 4px;
|
||||
|
|
|
@ -255,42 +255,43 @@ function Settings({ onClose }) {
|
|||
: ''
|
||||
}`}
|
||||
>
|
||||
<label>
|
||||
Translate to{' '}
|
||||
<select
|
||||
value={targetLanguage || ''}
|
||||
disabled={!snapStates.settings.contentTranslation}
|
||||
onChange={(e) => {
|
||||
states.settings.contentTranslationTargetLanguage =
|
||||
e.target.value || null;
|
||||
}}
|
||||
>
|
||||
<option value="">
|
||||
System language ({systemTargetLanguageText})
|
||||
</option>
|
||||
<option disabled>──────────</option>
|
||||
{targetLanguages.map((lang) => (
|
||||
<option value={lang.code}>{lang.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<div>
|
||||
<label>
|
||||
Translate to{' '}
|
||||
<select
|
||||
value={targetLanguage || ''}
|
||||
disabled={!snapStates.settings.contentTranslation}
|
||||
onChange={(e) => {
|
||||
states.settings.contentTranslationTargetLanguage =
|
||||
e.target.value || null;
|
||||
}}
|
||||
>
|
||||
<option value="">
|
||||
System language ({systemTargetLanguageText})
|
||||
</option>
|
||||
<option disabled>──────────</option>
|
||||
{targetLanguages.map((lang) => (
|
||||
<option value={lang.code}>{lang.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<hr />
|
||||
<p class="checkbox-fieldset">
|
||||
<small>
|
||||
Hide "Translate" button for
|
||||
{snapStates.settings.contentTranslationHideLanguages
|
||||
.length > 0 && (
|
||||
<>
|
||||
{' '}
|
||||
(
|
||||
{
|
||||
snapStates.settings.contentTranslationHideLanguages
|
||||
.length
|
||||
}
|
||||
)
|
||||
</>
|
||||
)}
|
||||
:
|
||||
</small>
|
||||
Hide "Translate" button for
|
||||
{snapStates.settings.contentTranslationHideLanguages.length >
|
||||
0 && (
|
||||
<>
|
||||
{' '}
|
||||
(
|
||||
{
|
||||
snapStates.settings.contentTranslationHideLanguages
|
||||
.length
|
||||
}
|
||||
)
|
||||
</>
|
||||
)}
|
||||
:
|
||||
<div class="checkbox-fields">
|
||||
{targetLanguages.map((lang) => (
|
||||
<label>
|
||||
|
@ -318,7 +319,7 @@ function Settings({ onClose }) {
|
|||
))}
|
||||
</div>
|
||||
</p>
|
||||
<p>
|
||||
<p class="insignificant">
|
||||
<small>
|
||||
Note: This feature uses an external API to translate,
|
||||
powered by{' '}
|
||||
|
@ -331,6 +332,28 @@ function Settings({ onClose }) {
|
|||
.
|
||||
</small>
|
||||
</p>
|
||||
<hr />
|
||||
<div>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={snapStates.settings.contentTranslationAutoInline}
|
||||
disabled={!snapStates.settings.contentTranslation}
|
||||
onChange={(e) => {
|
||||
states.settings.contentTranslationAutoInline =
|
||||
e.target.checked;
|
||||
}}
|
||||
/>{' '}
|
||||
Auto inline translation
|
||||
</label>
|
||||
<p class="insignificant">
|
||||
<small>
|
||||
Automatically show translation for posts in timeline. Only
|
||||
works for <b>short</b> posts without content warning,
|
||||
media and poll.
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -52,6 +52,8 @@ const states = proxy({
|
|||
store.account.get('settings-contentTranslationTargetLanguage') || null,
|
||||
contentTranslationHideLanguages:
|
||||
store.account.get('settings-contentTranslationHideLanguages') || [],
|
||||
contentTranslationAutoInline:
|
||||
store.account.get('settings-contentTranslationAutoInline') ?? false,
|
||||
cloakMode: store.account.get('settings-cloakMode') ?? false,
|
||||
},
|
||||
});
|
||||
|
@ -80,6 +82,9 @@ subscribe(states, (changes) => {
|
|||
if (path.join('.') === 'settings.contentTranslation') {
|
||||
store.account.set('settings-contentTranslation', !!value);
|
||||
}
|
||||
if (path.join('.') === 'settings.contentTranslationAutoInline') {
|
||||
store.account.set('settings-contentTranslationAutoInline', !!value);
|
||||
}
|
||||
if (path.join('.') === 'settings.contentTranslationTargetLanguage') {
|
||||
console.log('SET', value);
|
||||
store.account.set('settings-contentTranslationTargetLanguage', value);
|
||||
|
|
Loading…
Reference in a new issue