mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-24 02:51:43 +01:00
Fix language detection taking mentions and URLs into account (#33700)
This commit is contained in:
parent
8eee7ae4c3
commit
3178acc5cb
@ -8,6 +8,7 @@ import { debounce } from 'lodash';
|
||||
import { changeComposeLanguage } from 'mastodon/actions/compose';
|
||||
|
||||
import LanguageDropdown from '../components/language_dropdown';
|
||||
import { urlRegex } from '../util/url_regex';
|
||||
|
||||
const getFrequentlyUsedLanguages = createSelector([
|
||||
state => state.getIn(['settings', 'frequentlyUsedLanguages'], ImmutableMap()),
|
||||
@ -71,7 +72,16 @@ const ISO_639_MAP = {
|
||||
vie: 'vi', // Vietnamese
|
||||
};
|
||||
|
||||
const debouncedLande = debounce((text) => lande(text), 500, { trailing: true });
|
||||
const debouncedLande = debounce((text) => {
|
||||
text = text
|
||||
.replace(urlRegex, '')
|
||||
.replace(/(^|[^/\w])@(([a-z0-9_]+)@[a-z0-9.-]+[a-z0-9]+)/ig, '');
|
||||
|
||||
if (text.length <= 20)
|
||||
return undefined;
|
||||
|
||||
return lande(text);
|
||||
}, 500, { trailing: true });
|
||||
|
||||
const detectedLanguage = createSelector([
|
||||
state => state.getIn(['compose', 'text']),
|
||||
|
Loading…
x
Reference in New Issue
Block a user